{"thread":{"id":"8911","subject":"Minor bug in git-apply's patch-cleaning","startedAt":"2007-07-07T02:21:33Z","lastAt":"2007-07-08T12:47:05Z","messageCount":4,"participants":["Daniel Barkalow","Johannes Schindelin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"46673","messageId":"Pine.LNX.4.64.0707062155170.6977@iabervon.org","threadId":"8911","inReplyTo":null,"subject":"Minor bug in git-apply's patch-cleaning","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-07-07T02:21:33Z","receivedAt":"2007-07-07T02:21:33Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"If you apply in reverse a patch which adds junk (e.g., terminal \nwhitespace), it complains about the junk you're adding, even though (since \nit's in reverse) you're actually removing that junk.\n\nIt's arguable as to whether it should complain about junk in - lines with \n--reverse; it's likely that you care more about getting the patch \nunapplied exactly than not reintroducing removed whitespace. But \ncomplaining about junk in + lines is actually confusing.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"46703","messageId":"Pine.LNX.4.64.0707071849430.4093@racer.site","threadId":"8911","inReplyTo":"Pine.LNX.4.64.0707062155170.6977@iabervon.org","subject":"[PATCH] Fix \"apply --reverse\" with regard to whitespace","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-07T17:50:39Z","receivedAt":"2007-07-07T17:50:39Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\n\"git apply\" used to take check the whitespace in the wrong\ndirection.\n\nNoticed by Daniel Barkalow.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Fri, 6 Jul 2007, Daniel Barkalow wrote:\n\n\t> If you apply in reverse a patch which adds junk (e.g., terminal\n\t> whitespace), it complains about the junk you're adding, even \n\t> though (since it's in reverse) you're actually removing that \n\t> junk.\n\n\tThis fixes it.\n\n builtin-apply.c          |    6 +++++-\n t/t4116-apply-reverse.sh |    6 ++++++\n 2 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex c6f736c..0a0b4a9 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -1003,12 +1003,16 @@ static int parse_fragment(char *line, unsigned long size, struct patch *patch, s\n \t\t\ttrailing++;\n \t\t\tbreak;\n \t\tcase '-':\n+\t\t\tif (apply_in_reverse &&\n+\t\t\t\t\tnew_whitespace != nowarn_whitespace)\n+\t\t\t\tcheck_whitespace(line, len);\n \t\t\tdeleted++;\n \t\t\toldlines--;\n \t\t\ttrailing = 0;\n \t\t\tbreak;\n \t\tcase '+':\n-\t\t\tif (new_whitespace != nowarn_whitespace)\n+\t\t\tif (!apply_in_reverse &&\n+\t\t\t\t\tnew_whitespace != nowarn_whitespace)\n \t\t\t\tcheck_whitespace(line, len);\n \t\t\tadded++;\n \t\t\tnewlines--;\ndiff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh\nindex a7f5905..9ae2b3a 100755\n--- a/t/t4116-apply-reverse.sh\n+++ b/t/t4116-apply-reverse.sh\n@@ -82,4 +82,10 @@ test_expect_success 'apply in reverse without postimage' '\n \t)\n '\n \n+test_expect_success 'reversing a whitespace introduction' '\n+\tsed \"s/a/a /\" < file1 > file1.new &&\n+\tmv file1.new file1 &&\n+\tgit diff | git apply --reverse --whitespace=error\n+'\n+\n test_done\n-- \n1.5.3.rc0.2712.g125b7f\n"},{"id":"46741","messageId":"7vd4z32rqc.fsf@assigned-by-dhcp.cox.net","threadId":"8911","inReplyTo":"Pine.LNX.4.64.0707071849430.4093@racer.site","subject":"Re: [PATCH] Fix \"apply --reverse\" with regard to whitespace","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-08T09:02:19Z","receivedAt":"2007-07-08T09:02:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> \"git apply\" used to take check the whitespace in the wrong\n> direction.\n>\n> Noticed by Daniel Barkalow.\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>\n> \tOn Fri, 6 Jul 2007, Daniel Barkalow wrote:\n>\n> \t> If you apply in reverse a patch which adds junk (e.g., terminal\n> \t> whitespace), it complains about the junk you're adding, even \n> \t> though (since it's in reverse) you're actually removing that \n> \t> junk.\n>\n> \tThis fixes it.\n\nHmm.  Does this cover the \"trailing blank lines removal\" as\nwell?\n"},{"id":"46751","messageId":"Pine.LNX.4.64.0707081344000.4248@racer.site","threadId":"8911","inReplyTo":"7vd4z32rqc.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Fix \"apply --reverse\" with regard to whitespace","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-08T12:47:05Z","receivedAt":"2007-07-08T12:47:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 8 Jul 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > \"git apply\" used to take check the whitespace in the wrong\n> > direction.\n> >\n> > Noticed by Daniel Barkalow.\n> >\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> >\n> > \tOn Fri, 6 Jul 2007, Daniel Barkalow wrote:\n> >\n> > \t> If you apply in reverse a patch which adds junk (e.g., terminal\n> > \t> whitespace), it complains about the junk you're adding, even \n> > \t> though (since it's in reverse) you're actually removing that \n> > \t> junk.\n> >\n> > \tThis fixes it.\n> \n> Hmm.  Does this cover the \"trailing blank lines removal\" as\n> well?\n\n-- snip --\ndiff --git a/TODO b/TODO\nindex ecd2b85..8935376 100644\n--- a/TODO\n+++ b/TODO\n@@ -1,6 +1,5 @@\n+interdiff between commits\n diff with file/symlink\n-remote remove <nick>\n-libification: setjmp() error handler with xmalloc(), xcalloc(), xfree() handling\n fix diff_filepair() mess in diff.c\n merge -s rebase\n build in ls-remote\ndiff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh\nindex 9ae2b3a..f3f9181 100755\n--- a/t/t4116-apply-reverse.sh\n+++ b/t/t4116-apply-reverse.sh\n@@ -84,6 +84,7 @@ test_expect_success 'apply in reverse without postimage' '\n \n test_expect_success 'reversing a whitespace introduction' '\n \tsed \"s/a/a /\" < file1 > file1.new &&\n+\techo >> file1.new &&\n \tmv file1.new file1 &&\n \tgit diff | git apply --reverse --whitespace=error\n '\n-- snap --\n\nApparently.\n\nOr not.  Since a patch adding empty lines does not trigger any error with \n--whitespace=error.  I just tested that.\n\nCiao,\nDscho\n"}]}