[PATCH 73/83] builtin/apply: make write_out_results() return -1 on error
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin/apply.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index dae89e2..49ef4c9 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4367,6 +4367,12 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
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;
@@ -4381,7 +4387,7 @@ static int write_out_results(struct apply_state *state, struct patch *list)
errs = 1;
else {
if (write_out_one_result(state, l, phase))
- exit(1);
+ return -1;
if (phase == 1) {
if (write_out_one_reject(state, l))
errs = 1;
@@ -4484,11 +4490,16 @@ static int apply_patch(struct apply_state *state,
!state->apply_with_reject)
return -1;
- if (state->apply && write_out_results(state, list)) {
- if (state->apply_with_reject)
+ if (state->apply) {
+ int res = write_out_results(state, list);
+ if (res < 0)
return -1;
- /* with --3way, we still need to write the index out */
- return 1;
+ if (res > 0) {
+ if (state->apply_with_reject)
+ return -1;
+ /* with --3way, we still need to write the index out */
+ return 1;
+ }
}
if (state->fake_ancestor &&
--
2.8.1.300.g5fed0c0