@matheusbsbs / matheus-bagliano / commits / 5fda48d67c
Fork 0

Fix "apply --reverse" with regard to whitespace

"git apply" used to take check the whitespace in the wrong direction. Noticed by Daniel Barkalow. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 7, 2007 at 18:50 UTC 5fda48d67c82e07950e0b0c21cd8c97daefd7be0
2 files changed +11 -1
builtin-apply.c
+5 -1
@@ -1003,12 +1003,16 @@ static int parse_fragment(char *line, unsigned long size, struct patch *patch, s
1003 trailing++;
1004 break;
1005 case '-':
1006 + if (apply_in_reverse &&
1007 + new_whitespace != nowarn_whitespace)
1008 + check_whitespace(line, len);
1009 deleted++;
1010 oldlines--;
1011 trailing = 0;
1012 break;
1013 case '+':
1011 - if (new_whitespace != nowarn_whitespace)
1014 + if (!apply_in_reverse &&
1015 + new_whitespace != nowarn_whitespace)
1016 check_whitespace(line, len);
1017 added++;
1018 newlines--;
t/t4116-apply-reverse.sh
+6
@@ -82,4 +82,10 @@ test_expect_success 'apply in reverse without postimage' '
82 )
83 '
84
85 +test_expect_success 'reversing a whitespace introduction' '
86 + sed "s/a/a /" < file1 > file1.new &&
87 + mv file1.new file1 &&
88 + git diff | git apply --reverse --whitespace=error
89 +'
90 +
91 test_done