Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Sat, 7 Jul 2007 19:29:09 +0000 (12:29 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 7 Jul 2007 19:29:09 +0000 (12:29 -0700)
* maint:
Fix "apply --reverse" with regard to whitespace

builtin-apply.c
t/t4116-apply-reverse.sh
index c6f736c14e4840bde2efd204e7f88a3556e9eed9..0a0b4a9e3f6550b6a4729e94242811dcb6e8d09a 100644 (file)
@@ -1003,12 +1003,16 @@ static int parse_fragment(char *line, unsigned long size, struct patch *patch, s
                        trailing++;
                        break;
                case '-':
+                       if (apply_in_reverse &&
+                                       new_whitespace != nowarn_whitespace)
+                               check_whitespace(line, len);
                        deleted++;
                        oldlines--;
                        trailing = 0;
                        break;
                case '+':
-                       if (new_whitespace != nowarn_whitespace)
+                       if (!apply_in_reverse &&
+                                       new_whitespace != nowarn_whitespace)
                                check_whitespace(line, len);
                        added++;
                        newlines--;
index a7f5905f1e651fea6690bfbdb5857c68fc4fda27..9ae2b3a8efaad4430bbcea02152470b064263b2b 100755 (executable)
@@ -82,4 +82,10 @@ test_expect_success 'apply in reverse without postimage' '
        )
 '
 
+test_expect_success 'reversing a whitespace introduction' '
+       sed "s/a/a /" < file1 > file1.new &&
+       mv file1.new file1 &&
+       git diff | git apply --reverse --whitespace=error
+'
+
 test_done