diff options
author | Junio C Hamano <junkio@cox.net> | 2005-11-18 00:11:28 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-11-18 00:11:28 -0800 |
commit | 6eb668df76a5b46bd24c25d227bfdba12542b05a (patch) | |
tree | efbfbad73fbbb0a5a363bdaf30a2e3d3dfe0abc7 /apply.c | |
parent | 1e9eb2e93747d2ee3fb44a5a2c8a48e7d19819b9 (diff) | |
parent | 087b6742fcab74f7a53626b98969bed27d288e2b (diff) | |
download | git-6eb668df76a5b46bd24c25d227bfdba12542b05a.tar.gz |
Merge branch 'master'
Diffstat (limited to 'apply.c')
-rw-r--r-- | apply.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -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 |