summaryrefslogtreecommitdiff
path: root/builtin-apply.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2006-10-20 02:26:08 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-10-20 04:28:06 (GMT)
commitb507b465f7831612b9d9fc643e3e5218b64e5bfa (patch)
tree309972583a151079778743b0dd600fd0b541d6c7 /builtin-apply.c
parent6b09c7883f50044a68d93ef6872486bad2e93a9d (diff)
downloadgit-b507b465f7831612b9d9fc643e3e5218b64e5bfa.zip
git-b507b465f7831612b9d9fc643e3e5218b64e5bfa.tar.gz
git-b507b465f7831612b9d9fc643e3e5218b64e5bfa.tar.bz2
git-apply: prepare for upcoming GNU diff -u format change.
The latest GNU diff from CVS emits an empty line to express an empty context line, instead of more traditional "single white space followed by a newline". Do not get broken by it. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-apply.c')
-rw-r--r--builtin-apply.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin-apply.c b/builtin-apply.c
index cbe5977..11a5277 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -934,6 +934,7 @@ static int parse_fragment(char *line, unsigned long size, struct patch *patch, s
switch (*line) {
default:
return -1;
+ case '\n': /* newer GNU diff, an empty context line */
case ' ':
oldlines--;
newlines--;
@@ -1623,6 +1624,14 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag, i
first = '-';
}
switch (first) {
+ case '\n':
+ /* Newer GNU diff, empty context line */
+ if (plen < 0)
+ /* ... followed by '\No newline'; nothing */
+ break;
+ old[oldsize++] = '\n';
+ new[newsize++] = '\n';
+ break;
case ' ':
case '-':
memcpy(old + oldsize, patch + 1, plen);