return !state->has_include;
}
-
/*
* Read the patch text in "buffer" that extends for "size" bytes; stop
* reading after seeing a single patch (i.e. changes to a single file).
* Create fragments (i.e. patch hunks) and hang them to the given patch.
- * Return the number of bytes consumed, so that the caller can call us
- * again for the next patch.
+ *
+ * Returns:
+ * -1 if no header was found or parse_binary() failed,
+ * -128 on another error,
+ * the number of bytes consumed otherwise,
+ * so that the caller can call us again for the next patch.
*/
static int parse_chunk(struct apply_state *state, char *buffer, unsigned long size, struct patch *patch)
{
int hdrsize, patchsize;
int offset = find_header(state, buffer, size, &hdrsize, patch);
- if (offset == -128)
- exit(128);
-
if (offset < 0)
return offset;
* empty to us here.
*/
if ((state->apply || state->check) &&
- (!patch->is_binary && !metadata_changes(patch)))
- die(_("patch with only garbage at line %d"), state->linenr);
+ (!patch->is_binary && !metadata_changes(patch))) {
+ error(_("patch with only garbage at line %d"), state->linenr);
+ return -128;
+ }
}
return offset + hdrsize + patchsize;
nr = parse_chunk(state, buf.buf + offset, buf.len - offset, patch);
if (nr < 0) {
free_patch(patch);
+ if (nr == -128) {
+ res = -128;
+ goto end;
+ }
break;
}
if (state->apply_in_reverse)