aboutsummaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-11-17 20:46:29 -0800
committerJunio C Hamano <junkio@cox.net>2005-11-17 21:14:29 -0800
commit3200d1aee0c22a34d075aafefe3e92f4f7d08840 (patch)
tree7fc41709301f6370157181c94a78a1462c600b7f /apply.c
parenta575603af20a795584d79b32c30bda10fcae5d3f (diff)
downloadgit-3200d1aee0c22a34d075aafefe3e92f4f7d08840.tar.gz
git-3200d1aee0c22a34d075aafefe3e92f4f7d08840.tar.xz
Deal with binary diff output from GNU diff 2.8.7
Some vintage of diff says just "Files X and Y differ\n", instead of "Binary files X and Y differ\n", so catch both patterns. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/apply.c b/apply.c
index 129edb188..50be8f3e2 100644
--- a/apply.c
+++ b/apply.c
@@ -893,12 +893,24 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
patchsize = parse_single_patch(buffer + offset + hdrsize, size - offset - hdrsize, patch);
if (!patchsize) {
- static const char binhdr[] = "Binary files ";
-
- if (sizeof(binhdr) - 1 < size - offset - hdrsize &&
- !memcmp(binhdr, buffer + hdrsize + offset,
- sizeof(binhdr)-1))
- patch->is_binary = 1;
+ static const char *binhdr[] = {
+ "Binary files ",
+ "Files ",
+ NULL,
+ };
+ int i;
+ int hd = hdrsize + offset;
+ unsigned long llen = linelen(buffer + hd, size - hd);
+
+ if (!memcmp(" differ\n", buffer + hd + llen - 8, 8))
+ for (i = 0; binhdr[i]; i++) {
+ int len = strlen(binhdr[i]);
+ if (len < size - hd &&
+ !memcmp(binhdr[i], buffer + hd, len)) {
+ patch->is_binary = 1;
+ break;
+ }
+ }
/* Empty patch cannot be applied if:
* - it is a binary patch and we do not do binary_replace, or