summaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/apply.c b/apply.c
index 590adc6..a002e15 100644
--- a/apply.c
+++ b/apply.c
@@ -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);
}