{"thread":{"id":"37628","subject":"[PATCH] git-quiltimport.sh: disallow fuzz","startedAt":"2014-09-24T21:35:12Z","lastAt":"2014-10-21T21:38:00Z","messageCount":8,"participants":["Jörn Engel","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"249838","messageId":"20140924213512.GA7619@logfs.org","threadId":"37628","inReplyTo":null,"subject":"[PATCH] git-quiltimport.sh: disallow fuzz","fromName":"Jörn Engel","fromEmail":"joern@logfs.org","sentAt":"2014-09-24T21:35:12Z","receivedAt":"2014-09-24T21:35:12Z","isPatch":true,"sender":{"key":"joern@logfs.org","avatar":null},"body":"git-quiltimport passed \"-C1\" to git-apply, supposedly to roughly match\nthe quilt default of --fuzz 2.  This is against the spirit of git.\nQuoting Linus:\n  Except unlike the standard \"patch\" program, \"git apply\" doesn't accept\n  fuzz by default (which to me is a huge deal - I hate how \"patch\" tries\n  to apply stuff that clearly isn't valid any more)\n\nIt also causes active harm when combining git-quiltimport with regular\nquilt and quilt is used with --fuzz=0, as it should be by any prudent \nperson.\n\nSigned-off-by: Joern Engel <joern@logfs.org>\n---\n git-quiltimport.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-quiltimport.sh b/git-quiltimport.sh\nindex 167d79fea809..3eb2e2fd3648 100755\n--- a/git-quiltimport.sh\n+++ b/git-quiltimport.sh\n@@ -130,7 +130,7 @@ do\n \tfi\n \n \tif [ -z \"$dry_run\" ] ; then\n-\t\tgit apply --index -C1 ${level:+\"$level\"} \"$tmp_patch\" &&\n+\t\tgit apply --index ${level:+\"$level\"} \"$tmp_patch\" &&\n \t\ttree=$(git write-tree) &&\n \t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\n \t\tgit update-ref -m \"quiltimport: $patch_name\" HEAD $commit || exit 4\n-- \n2.1.0\n"},{"id":"249841","messageId":"xmqqwq8sb81e.fsf@gitster.dls.corp.google.com","threadId":"37628","inReplyTo":"20140924213512.GA7619@logfs.org","subject":"Re: [PATCH] git-quiltimport.sh: disallow fuzz","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-09-25T05:09:33Z","receivedAt":"2014-09-25T05:09:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jörn Engel <joern@logfs.org> writes:\n\n> git-quiltimport passed \"-C1\" to git-apply, supposedly to roughly match\n> the quilt default of --fuzz 2.  This is against the spirit of git.\n> Quoting Linus:\n>   Except unlike the standard \"patch\" program, \"git apply\" doesn't accept\n>   fuzz by default (which to me is a huge deal - I hate how \"patch\" tries\n>   to apply stuff that clearly isn't valid any more)\n>\n> It also causes active harm when combining git-quiltimport with regular\n> quilt and quilt is used with --fuzz=0,...\n\nThis is fine for those who use quilt with --fuzz=0, but how are you\nhelping those who use quilt without --fuzz=0?\n\nI agree that unconditionally passing -C1 is a bad thing, but\nunconditionally passing -C2 is not that better.  Shouldn't this be\ndone by introducing a new --fuzz=<number> option to quiltimport?\n\n\n>\n> Signed-off-by: Joern Engel <joern@logfs.org>\n> ---\n>  git-quiltimport.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/git-quiltimport.sh b/git-quiltimport.sh\n> index 167d79fea809..3eb2e2fd3648 100755\n> --- a/git-quiltimport.sh\n> +++ b/git-quiltimport.sh\n> @@ -130,7 +130,7 @@ do\n>  \tfi\n>  \n>  \tif [ -z \"$dry_run\" ] ; then\n> -\t\tgit apply --index -C1 ${level:+\"$level\"} \"$tmp_patch\" &&\n> +\t\tgit apply --index ${level:+\"$level\"} \"$tmp_patch\" &&\n>  \t\ttree=$(git write-tree) &&\n>  \t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\n>  \t\tgit update-ref -m \"quiltimport: $patch_name\" HEAD $commit || exit 4\n"},{"id":"249869","messageId":"20140925220831.GA14433@logfs.org","threadId":"37628","inReplyTo":"xmqqwq8sb81e.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-quiltimport.sh: disallow fuzz","fromName":"Jörn Engel","fromEmail":"joern@logfs.org","sentAt":"2014-09-25T22:08:31Z","receivedAt":"2014-09-25T22:08:31Z","isPatch":true,"sender":{"key":"joern@logfs.org","avatar":null},"body":"On Wed, 24 September 2014 22:09:33 -0700, Junio C Hamano wrote:\n> \n> This is fine for those who use quilt with --fuzz=0, but how are you\n> helping those who use quilt without --fuzz=0?\n> \n> I agree that unconditionally passing -C1 is a bad thing, but\n> unconditionally passing -C2 is not that better.  Shouldn't this be\n> done by introducing a new --fuzz=<number> option to quiltimport?\n\nMaybe the patch below then?  Defaulting to no fuzz is both me\nenforcing my (and Linus') preference and that alternatives are hard\nand messy.  How would one specify fuzz=0?  -C3 would work for standard\npatches, but be wrong for patches with more context.  -C0 would\narguably also be wrong.  There really is no good choice.  And I won't\nadd a fuzz parameter until git-apply has one, as it can only be\ntransformed to -C by either making assumptions about the context or\nparsing the patches - ick!\n\nJörn\n\n--\nWhen I am working on a problem I never think about beauty.  I think\nonly how to solve the problem.  But when I have finished, if the\nsolution is not beautiful, I know it is wrong.\n-- R. Buckminster Fuller\n\nSubject: [PATCH] git-quiltimport.sh: disallow fuzz by default\n\ngit-quiltimport passed \"-C1\" to git-apply, supposedly to roughly match\nthe quilt default of --fuzz 2.  This is against the spirit of git.\nQuoting Linus:\n  Except unlike the standard \"patch\" program, \"git apply\" doesn't accept\n  fuzz by default (which to me is a huge deal - I hate how \"patch\" tries\n  to apply stuff that clearly isn't valid any more)\n\nUsers that want to want to emulate quilt defaults can pass \"-C 1\" to\ngit-quiltimport now.\n\nAlso note that -C1 and fuzz=2 is not identical.  Most patches have three\nlines of context, so fuzz=2 leaves one relevant line of context.  But\nfor any patches with more or less context this is not true.  git-apply\nhas no option for fuzz, so any emulation will always be best-effort.\n\nSigned-off-by: Joern Engel <joern@logfs.org>\n---\n git-quiltimport.sh | 15 +++++++++++++--\n 1 file changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/git-quiltimport.sh b/git-quiltimport.sh\nindex 167d79fea809..f45ee5ff6599 100755\n--- a/git-quiltimport.sh\n+++ b/git-quiltimport.sh\n@@ -4,8 +4,9 @@ OPTIONS_STUCKLONG=\n OPTIONS_SPEC=\"\\\n git quiltimport [options]\n --\n-n,dry-run     dry run\n author=       author name and email address for patches without any\n+C=            minimum context (see git apply)\n+n,dry-run     dry run\n patches=      path to the quilt series and patches\n \"\n SUBDIRECTORY_ON=Yes\n@@ -13,6 +14,7 @@ SUBDIRECTORY_ON=Yes\n \n dry_run=\"\"\n quilt_author=\"\"\n+cflag=\"\"\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -20,6 +22,15 @@ do\n \t\tshift\n \t\tquilt_author=\"$1\"\n \t\t;;\n+\t-C)\n+\t\tshift\n+\t\t# ensure numerical parameter\n+\t\tcase $1 in\n+\t\t\t''|*[!0-9]*) usage;;\n+\t\t\t*) ;;\n+\t\tesac\n+\t\tcflag=\"-C$1\"\n+\t\t;;\n \t-n|--dry-run)\n \t\tdry_run=1\n \t\t;;\n@@ -130,7 +141,7 @@ do\n \tfi\n \n \tif [ -z \"$dry_run\" ] ; then\n-\t\tgit apply --index -C1 ${level:+\"$level\"} \"$tmp_patch\" &&\n+\t\tgit apply --index $cflag ${level:+\"$level\"} \"$tmp_patch\" &&\n \t\ttree=$(git write-tree) &&\n \t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\n \t\tgit update-ref -m \"quiltimport: $patch_name\" HEAD $commit || exit 4\n-- \n2.1.0\n"},{"id":"249870","messageId":"xmqq7g0r9v04.fsf@gitster.dls.corp.google.com","threadId":"37628","inReplyTo":"20140925220831.GA14433@logfs.org","subject":"Re: [PATCH] git-quiltimport.sh: disallow fuzz","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-09-25T22:48:43Z","receivedAt":"2014-09-25T22:48:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jörn Engel <joern@logfs.org> writes:\n\n> When I am working on a problem I never think about beauty.  I think\n> only how to solve the problem.  But when I have finished, if the\n> solution is not beautiful, I know it is wrong.\n> -- R. Buckminster Fuller\n\nNice quote, but does not belong to above --- lines, unless you have\na -- >8 -- line below or something.\n\nNow is the patch beautiful? ;-)\n\n> Subject: [PATCH] git-quiltimport.sh: disallow fuzz by default\n>\n> git-quiltimport passed \"-C1\" to git-apply, supposedly to roughly match\n> the quilt default of --fuzz 2.  This is against the spirit of git.\n> Quoting Linus:\n>   Except unlike the standard \"patch\" program, \"git apply\" doesn't accept\n>   fuzz by default (which to me is a huge deal - I hate how \"patch\" tries\n>   to apply stuff that clearly isn't valid any more)\n> Users that want to want to emulate quilt defaults can pass \"-C 1\" to\n> git-quiltimport now.\n\nThings might have been different if this were mid 2006 or early\n2007, but I am afraid that \"the spirit of git\" with a quote from\nLinus no longer carries much weight on this particular issue.  A\nbackward incompatible change is backward incompatible change that\nbreaks existing users no matter how loudly you (and I) shout that it\nis the right thing to do in the long run.\n\nLet's have it the other way around, keep the same behaviour for\nthose who run the command without the new option, while allowing\npeople who know better and are aligned with the spirit of git to\npass the parameter, at least for now, with a note in the\ndocumentation to warn that the default may change in the future to\nallow no fuzz, or something.\n\n> Also note that -C1 and fuzz=2 is not identical.  Most patches have three\n> lines of context, so fuzz=2 leaves one relevant line of context.  But\n> for any patches with more or less context this is not true.  git-apply\n> has no option for fuzz, so any emulation will always be best-effort.\n>\n> Signed-off-by: Joern Engel <joern@logfs.org>\n> ---\n>  git-quiltimport.sh | 15 +++++++++++++--\n>  1 file changed, 13 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-quiltimport.sh b/git-quiltimport.sh\n> index 167d79fea809..f45ee5ff6599 100755\n> --- a/git-quiltimport.sh\n> +++ b/git-quiltimport.sh\n> @@ -4,8 +4,9 @@ OPTIONS_STUCKLONG=\n>  OPTIONS_SPEC=\"\\\n>  git quiltimport [options]\n>  --\n> -n,dry-run     dry run\n>  author=       author name and email address for patches without any\n> +C=            minimum context (see git apply)\n> +n,dry-run     dry run\n>  patches=      path to the quilt series and patches\n>  \"\n>  SUBDIRECTORY_ON=Yes\n> @@ -13,6 +14,7 @@ SUBDIRECTORY_ON=Yes\n>  \n>  dry_run=\"\"\n>  quilt_author=\"\"\n> +cflag=\"\"\n>  while test $# != 0\n>  do\n>  \tcase \"$1\" in\n> @@ -20,6 +22,15 @@ do\n>  \t\tshift\n>  \t\tquilt_author=\"$1\"\n>  \t\t;;\n> +\t-C)\n> +\t\tshift\n> +\t\t# ensure numerical parameter\n> +\t\tcase $1 in\n> +\t\t\t''|*[!0-9]*) usage;;\n> +\t\t\t*) ;;\n> +\t\tesac\n> +\t\tcflag=\"-C$1\"\n> +\t\t;;\n>  \t-n|--dry-run)\n>  \t\tdry_run=1\n>  \t\t;;\n> @@ -130,7 +141,7 @@ do\n>  \tfi\n>  \n>  \tif [ -z \"$dry_run\" ] ; then\n> -\t\tgit apply --index -C1 ${level:+\"$level\"} \"$tmp_patch\" &&\n> +\t\tgit apply --index $cflag ${level:+\"$level\"} \"$tmp_patch\" &&\n>  \t\ttree=$(git write-tree) &&\n>  \t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\n>  \t\tgit update-ref -m \"quiltimport: $patch_name\" HEAD $commit || exit 4\n"},{"id":"249871","messageId":"xmqq1tqz9uhm.fsf@gitster.dls.corp.google.com","threadId":"37628","inReplyTo":"xmqq7g0r9v04.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-quiltimport.sh: disallow fuzz","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-09-25T22:59:49Z","receivedAt":"2014-09-25T22:59:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Let's have it the other way around, keep the same behaviour for\n> those who run the command without the new option, while allowing\n> people who know better and are aligned with the spirit of git to\n> pass the parameter, at least for now, with a note in the\n> documentation to warn that the default may change in the future to\n> allow no fuzz, or something.\n\nPerhaps like this, with some documentation added (do we have/need\nany test???).\n\n-- >8 --\nTo: Jörn Engel <joern@logfs.org>\nDate: Thu, 25 Sep 2014 18:08:31 -0400\nSubject: [PATCH] git-quiltimport.sh: allow declining fuzz with --exact option\n\ngit-quiltimport unconditionally passes \"-C1\" to \"git apply\",\nsupposedly to roughly match the quilt default of --fuzz 2.  Allow\nusers to pass --exact option to disable it, requiring the patch to\napply without any fuzz.\n\nAlso note that -C1 and fuzz=2 is not identical.  Most patches have\nthree lines of context, so fuzz=2 leaves one relevant line of\ncontext.  But for any patches with more or less context this is not\ntrue.  git-apply has no option for fuzz, so any emulation will\nalways be best-effort.\n\nSigned-off-by: Joern Engel <joern@logfs.org>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-quiltimport.txt | 12 ++++++++++++\n git-quiltimport.sh                | 17 ++++++++++++++++-\n 2 files changed, 28 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt\nindex a356196..109918d 100644\n--- a/Documentation/git-quiltimport.txt\n+++ b/Documentation/git-quiltimport.txt\n@@ -49,6 +49,18 @@ The default for the patch directory is patches\n or the value of the $QUILT_PATCHES environment\n variable.\n \n+-C <number>::\n+\tPass `-C<number>` to underlying `git apply` when applying\n+\tthe patch, to reduce number of context lines to be matched.\n+\tBy default, `-C1` is passed to `git apply` to emulate the\n+\t`--fuzz=2` behaviour of quilt (assuming the standard 3\n+\tcontext lines).\n+\n+--exact::\n+\tDo not pass any `-C<number>` option to `git apply` when\n+\tapplying the patch, to require context lines to fully match.\n+\n+\n GIT\n ---\n Part of the linkgit:git[1] suite\ndiff --git a/git-quiltimport.sh b/git-quiltimport.sh\nindex 167d79f..2d2c377 100755\n--- a/git-quiltimport.sh\n+++ b/git-quiltimport.sh\n@@ -6,6 +6,8 @@ git quiltimport [options]\n --\n n,dry-run     dry run\n author=       author name and email address for patches without any\n+C=            minimum context (see git apply)\n+exact         allow no-fuzz\n patches=      path to the quilt series and patches\n \"\n SUBDIRECTORY_ON=Yes\n@@ -13,6 +15,7 @@ SUBDIRECTORY_ON=Yes\n \n dry_run=\"\"\n quilt_author=\"\"\n+cflag=-C1\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -20,6 +23,18 @@ do\n \t\tshift\n \t\tquilt_author=\"$1\"\n \t\t;;\n+\t-C)\n+\t\tshift\n+\t\t# ensure numerical parameter\n+\t\tcase \"$1\" in\n+\t\t''|*[!0-9]*) usage;;\n+\t\t*) ;;\n+\t\tesac\n+\t\tcflag=\"-C$1\"\n+\t\t;;\n+\t--exact)\n+\t\tcflag=\n+\t\t;;\n \t-n|--dry-run)\n \t\tdry_run=1\n \t\t;;\n@@ -130,7 +145,7 @@ do\n \tfi\n \n \tif [ -z \"$dry_run\" ] ; then\n-\t\tgit apply --index -C1 ${level:+\"$level\"} \"$tmp_patch\" &&\n+\t\tgit apply --index $cflag ${level:+\"$level\"} \"$tmp_patch\" &&\n \t\ttree=$(git write-tree) &&\n \t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\n \t\tgit update-ref -m \"quiltimport: $patch_name\" HEAD $commit || exit 4\n-- \n2.1.1-394-g5293c25\n"},{"id":"249920","messageId":"xmqq4mvu859h.fsf@gitster.dls.corp.google.com","threadId":"37628","inReplyTo":"xmqq1tqz9uhm.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-quiltimport.sh: disallow fuzz","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-09-26T21:02:18Z","receivedAt":"2014-09-26T21:02:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Perhaps like this, with some documentation added (do we have/need\n> any test???).\n>\n> -- >8 --\n> Date: Thu, 25 Sep 2014 18:08:31 -0400\n> Subject: [PATCH] git-quiltimport.sh: allow declining fuzz with --exact option\n\nAnd on top of that change, if somebody really wants to enforce\nstricter check by default, I think we could do something like this.\n\nObviously not tested at all, as I do not care too deeply myself ;-)\n\n-- >8 --\nSubject: [PATCH] git-quiltimport: flip the default not to allow fuzz\n\nTrying to be as strict as possible when applying the patch may be a\ngood discipline, so let's flip the default but we can be helpful to\nthose who do rely on the original behaviour thanks to the previous\nchange to add -C$n option.\n\nSuggest using -C1 when:\n\n - \"git apply\" without fuzz fails to apply; and\n - the user did not specify a -C$n or --exact option; and\n - \"git apply -C1\" (old behaviour) would have succeeded.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-quiltimport.sh | 26 ++++++++++++++++++++++++--\n 1 file changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/git-quiltimport.sh b/git-quiltimport.sh\nindex 929365f..01de26d 100755\n--- a/git-quiltimport.sh\n+++ b/git-quiltimport.sh\n@@ -15,7 +15,8 @@ SUBDIRECTORY_ON=Yes\n \n dry_run=\"\"\n quilt_author=\"\"\n-cflag=-C1\n+cflag=\n+fuzz_specified=\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -31,9 +32,11 @@ do\n \t\t*) ;;\n \t\tesac\n \t\tcflag=\"-C$1\"\n+\t\tfuzz_specified=yes\n \t\t;;\n \t--exact)\n \t\tcflag=\n+\t\tfuzz_specified=yes\n \t\t;;\n \t-n|--dry-run)\n \t\tdry_run=1\n@@ -74,6 +77,25 @@ tmp_msg=\"$tmp_dir/msg\"\n tmp_patch=\"$tmp_dir/patch\"\n tmp_info=\"$tmp_dir/info\"\n \n+# Helper to warn about -C$n option\n+do_apply () {\n+\tif git apply --index $cflag \"$@\"\n+\tthen\n+\t\treturn\n+\tfi\n+\tif test -z \"$fuzz_specified\" &&\n+\t   git apply --check --index -C1 \"$@\" >/dev/null 2>&1\n+\tthen\n+\t\tcat >&2 <<-\\EOM\n+\t\t'git quiltimport' by default no longer attempts to apply\n+\t\tpatches with reduced context lines to allow fuzz; if you\n+\t\twant the old 'unsafe' behaviour, run the command with -C1\n+\t\toption.\n+\t\tEOM\n+\n+\tfi\n+\treturn 1\n+}\n \n # Find the initial commit\n commit=$(git rev-parse HEAD)\n@@ -145,7 +167,7 @@ do\n \tfi\n \n \tif [ -z \"$dry_run\" ] ; then\n-\t\tgit apply --index $cflag ${level:+\"$level\"} \"$tmp_patch\" &&\n+\t\tdo_apply ${level:+\"$level\"} \"$tmp_patch\" &&\n \t\ttree=$(git write-tree) &&\n \t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\n \t\tgit update-ref -m \"quiltimport: $patch_name\" HEAD $commit || exit 4\n-- \n2.1.1-394-g5293c25\n"},{"id":"250949","messageId":"xmqqd29lyuq1.fsf@gitster.dls.corp.google.com","threadId":"37628","inReplyTo":"xmqq7g0r9v04.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-quiltimport.sh: disallow fuzz","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-10-21T21:32:38Z","receivedAt":"2014-10-21T21:32:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Things might have been different if this were mid 2006 or early\n> 2007, but I am afraid that \"the spirit of git\" with a quote from\n> Linus no longer carries much weight on this particular issue.  A\n> backward incompatible change is backward incompatible change that\n> breaks existing users no matter how loudly you (and I) shout that it\n> is the right thing to do in the long run.\n>\n> Let's have it the other way around, keep the same behaviour for\n> those who run the command without the new option, while allowing\n> people who know better and are aligned with the spirit of git to\n> pass the parameter, at least for now, with a note in the\n> documentation to warn that the default may change in the future to\n> allow no fuzz, or something.\n\nI was waiting to hear an Ack or some comments and then forgot about\nthis topic.\n\nI'll send two patches, one is essentially yours *but* does not\nflip the default (i.e. those who want to be safe have to be explicit\nabout it), and then the other is to flip the default but more gently.\n\nHere is the first one.  I'll send the \"default flipping\" as a reply\nto this message.\n\n-- >8 --\nFrom: Joern Engel <joern@logfs.org>\nDate: Thu, 25 Sep 2014 18:08:31 -0400\nSubject: [PATCH 1/2] git-quiltimport.sh: allow declining fuzz with --exact option\n\ngit-quiltimport unconditionally passes \"-C1\" to \"git apply\",\nsupposedly to roughly match the quilt default of --fuzz 2.  Allow\nusers to pass --exact option to disable it, requiring the patch to\napply without any fuzz.\n\nAlso note that -C1 and fuzz=2 is not identical.  Most patches have\nthree lines of context, so fuzz=2 leaves one relevant line of\ncontext.  But for any patches with more or less context this is not\ntrue.  git-apply has no option for fuzz, so any emulation will\nalways be best-effort.\n\nSigned-off-by: Joern Engel <joern@logfs.org>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-quiltimport.txt | 12 ++++++++++++\n git-quiltimport.sh                | 17 ++++++++++++++++-\n 2 files changed, 28 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt\nindex a356196..109918d 100644\n--- a/Documentation/git-quiltimport.txt\n+++ b/Documentation/git-quiltimport.txt\n@@ -49,6 +49,18 @@ The default for the patch directory is patches\n or the value of the $QUILT_PATCHES environment\n variable.\n \n+-C <number>::\n+\tPass `-C<number>` to underlying `git apply` when applying\n+\tthe patch, to reduce number of context lines to be matched.\n+\tBy default, `-C1` is passed to `git apply` to emulate the\n+\t`--fuzz=2` behaviour of quilt (assuming the standard 3\n+\tcontext lines).\n+\n+--exact::\n+\tDo not pass any `-C<number>` option to `git apply` when\n+\tapplying the patch, to require context lines to fully match.\n+\n+\n GIT\n ---\n Part of the linkgit:git[1] suite\ndiff --git a/git-quiltimport.sh b/git-quiltimport.sh\nindex 167d79f..929365f 100755\n--- a/git-quiltimport.sh\n+++ b/git-quiltimport.sh\n@@ -6,6 +6,8 @@ git quiltimport [options]\n --\n n,dry-run     dry run\n author=       author name and email address for patches without any\n+C=            minimum context (see git apply)\n+exact         allow no-fuzz\n patches=      path to the quilt series and patches\n \"\n SUBDIRECTORY_ON=Yes\n@@ -13,6 +15,7 @@ SUBDIRECTORY_ON=Yes\n \n dry_run=\"\"\n quilt_author=\"\"\n+cflag=-C1\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -20,6 +23,18 @@ do\n \t\tshift\n \t\tquilt_author=\"$1\"\n \t\t;;\n+\t-C)\n+\t\tshift\n+\t\t# ensure numerical parameter\n+\t\tcase \"$1\" in\n+\t\t''|*[!0-9]*) usage;;\n+\t\t*) ;;\n+\t\tesac\n+\t\tcflag=\"-C$1\"\n+\t\t;;\n+\t--exact)\n+\t\tcflag=\n+\t\t;;\n \t-n|--dry-run)\n \t\tdry_run=1\n \t\t;;\n@@ -130,7 +145,7 @@ do\n \tfi\n \n \tif [ -z \"$dry_run\" ] ; then\n-\t\tgit apply --index -C1 ${level:+\"$level\"} \"$tmp_patch\" &&\n+\t\tgit apply --index $cflag ${level:+\"$level\"} \"$tmp_patch\" &&\n \t\ttree=$(git write-tree) &&\n \t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\n \t\tgit update-ref -m \"quiltimport: $patch_name\" HEAD $commit || exit 4\n-- \n2.1.2-583-g325e495\n"},{"id":"250950","messageId":"xmqq38ahje87.fsf_-_@gitster.dls.corp.google.com","threadId":"37628","inReplyTo":"xmqq7g0r9v04.fsf@gitster.dls.corp.google.com","subject":"[PATCH 2/2] git-quiltimport: flip the default not to allow fuzz","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-10-21T21:38:00Z","receivedAt":"2014-10-21T21:38:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Trying to be as strict as possible when applying the patch may be a\ngood discipline, so let's flip the default but we can be helpful to\nthose who do rely on the original behaviour thanks to the previous\nchange to add -C$n option.\n\nSuggest using -C1 when (and only when):\n\n - \"git apply\" without fuzz fails to apply; and\n - the user did not specify a -C$n or --exact option; and\n - \"git apply -C1\" (old behaviour) would have succeeded.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * And this is the \"flipping of the default\"\n\n git-quiltimport.sh | 26 ++++++++++++++++++++++++--\n 1 file changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/git-quiltimport.sh b/git-quiltimport.sh\nindex 929365f..1190eb9 100755\n--- a/git-quiltimport.sh\n+++ b/git-quiltimport.sh\n@@ -15,7 +15,8 @@ SUBDIRECTORY_ON=Yes\n \n dry_run=\"\"\n quilt_author=\"\"\n-cflag=-C1\n+cflag=\n+fuzz_specified=\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -31,9 +32,11 @@ do\n \t\t*) ;;\n \t\tesac\n \t\tcflag=\"-C$1\"\n+\t\tfuzz_specified=yes\n \t\t;;\n \t--exact)\n \t\tcflag=\n+\t\tfuzz_specified=yes\n \t\t;;\n \t-n|--dry-run)\n \t\tdry_run=1\n@@ -74,6 +77,25 @@ tmp_msg=\"$tmp_dir/msg\"\n tmp_patch=\"$tmp_dir/patch\"\n tmp_info=\"$tmp_dir/info\"\n \n+# Helper to warn about -C$n option\n+do_apply () {\n+\tif git apply --index ${cflag+\"$cflag\"} \"$@\"\n+\tthen\n+\t\treturn\n+\tfi\n+\tif test -z \"$fuzz_specified\" &&\n+\t   git apply --check --index -C1 \"$@\" >/dev/null 2>&1\n+\tthen\n+\t\tcat >&2 <<-\\EOM\n+\t\t'git quiltimport' by default no longer attempts to apply\n+\t\tpatches with reduced context lines to allow fuzz; if you\n+\t\twant the old 'unsafe' behaviour, run the command with -C1\n+\t\toption.\n+\t\tEOM\n+\n+\tfi\n+\treturn 1\n+}\n \n # Find the initial commit\n commit=$(git rev-parse HEAD)\n@@ -145,7 +167,7 @@ do\n \tfi\n \n \tif [ -z \"$dry_run\" ] ; then\n-\t\tgit apply --index $cflag ${level:+\"$level\"} \"$tmp_patch\" &&\n+\t\tdo_apply ${level:+\"$level\"} \"$tmp_patch\" &&\n \t\ttree=$(git write-tree) &&\n \t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\n \t\tgit update-ref -m \"quiltimport: $patch_name\" HEAD $commit || exit 4\n-- \n2.1.2-583-g325e495\n"}]}