summaryrefslogtreecommitdiff
path: root/builtin-apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-10-20 04:28:12 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-10-20 04:28:12 (GMT)
commite19343ad547e32aaf511b0b38be083e1b3145d4e (patch)
treebb2001ed8cb2b4857f5694f80a108bdb1e9fecb9 /builtin-apply.c
parent7768e27e1d3f3d5e253e795433033b5de1d1c157 (diff)
parentb507b465f7831612b9d9fc643e3e5218b64e5bfa (diff)
downloadgit-e19343ad547e32aaf511b0b38be083e1b3145d4e.zip
git-e19343ad547e32aaf511b0b38be083e1b3145d4e.tar.gz
git-e19343ad547e32aaf511b0b38be083e1b3145d4e.tar.bz2
Merge branch 'maint'
* maint: git-apply: prepare for upcoming GNU diff -u format change.
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 0bdcf63..11397f5 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);