return -1;
}
+/*
+ * Returns:
+ * -1 if an error happened
+ * 0 if the patch applied cleanly
+ * 1 if the patch did not apply cleanly
+ */
static int write_out_results(struct apply_state *state, struct patch *list)
{
int phase;
if (l->rejected)
errs = 1;
else {
- if (write_out_one_result(state, l, phase))
- exit(128);
+ if (write_out_one_result(state, l, phase)) {
+ string_list_clear(&cpath, 0);
+ return -1;
+ }
if (phase == 1) {
if (write_out_one_reject(state, l))
errs = 1;
}
}
- if (state->apply && write_out_results(state, list)) {
- /* with --3way, we still need to write the index out */
- res = state->apply_with_reject ? -1 : 1;
- goto end;
+ if (state->apply) {
+ int write_res = write_out_results(state, list);
+ if (write_res < 0) {
+ res = -128;
+ goto end;
+ }
+ if (write_res > 0) {
+ /* with --3way, we still need to write the index out */
+ res = state->apply_with_reject ? -1 : 1;
+ goto end;
+ }
}
if (state->fake_ancestor &&