]> Pileus Git - ~andy/git/commitdiff
git-apply: do not fix whitespaces on context lines.
authorJunio C Hamano <junkio@cox.net>
Tue, 27 Feb 2007 09:31:42 +0000 (01:31 -0800)
committerJunio C Hamano <junkio@cox.net>
Tue, 27 Feb 2007 09:33:14 +0000 (01:33 -0800)
Internal function apply_line() is called to copy both context lines
and added lines to the output buffer, while possibly fixing the
whitespace breakages depending on --whitespace=strip settings.
However, it did its fix-up on both context lines and added lines.

This resulted in two symptoms:

 (1) The number of lines reported to have been fixed up included
     these context lines.

 (2) However, the lines actually shown were limited to the added
     lines that had whitespace breakages.

Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-apply.c

index abe35387156cf2774c8bc619d74b93c5e83285a8..bec95d6c8aa60ac40718f52da5a8f9603330dadb 100644 (file)
@@ -1539,7 +1539,8 @@ static int apply_line(char *output, const char *patch, int plen)
        int need_fix_leading_space = 0;
        char *buf;
 
-       if ((new_whitespace != strip_whitespace) || !whitespace_error) {
+       if ((new_whitespace != strip_whitespace) || !whitespace_error ||
+           *patch != '+') {
                memcpy(output, patch + 1, plen);
                return plen;
        }