diff options
author | Junio C Hamano <junkio@cox.net> | 2005-11-16 14:12:56 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-11-16 14:12:56 -0800 |
commit | 92927ed0aac56a86f85049215791fcd106af4b62 (patch) | |
tree | 7c9261390297ed1d52097d2dd2fc76b9a1b337b6 /apply.c | |
parent | 5b4525eb8b6a4a131d0cc10075165829f754dcc2 (diff) | |
download | git-92927ed0aac56a86f85049215791fcd106af4b62.tar.gz |
git-apply: fail if a patch cannot be applied.
Recently we fixed 'git-apply --stat' not to barf on a binary
differences. But it accidentally broke the error detection when
we actually attempt to apply them.
This commit fixes the problem and adds test cases.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'apply.c')
-rw-r--r-- | apply.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -891,7 +891,7 @@ 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 && !metadata_changes(patch)) { + if (!patchsize) { static const char binhdr[] = "Binary files "; if (sizeof(binhdr) - 1 < size - offset - hdrsize && @@ -899,9 +899,12 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch) sizeof(binhdr)-1)) patch->is_binary = 1; - if (patch->is_binary && !apply && !check) - ; - else + /* Empty patch cannot be applied if: + * - it is a binary patch or + * - metadata does not change and is not a binary patch. + */ + if ((apply || check) && + (patch->is_binary || !metadata_changes(patch))) die("patch with only garbage at line %d", linenr); } |