[PATCH 81/83] apply: roll back index in case of error
From: Christian Couder <hidden>
Date: 2016-06-16 02:18:57
Subsystem:
the rest · Maintainer:
Linus Torvalds
Signed-off-by: Christian Couder <redacted> --- apply.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/apply.c b/apply.c
index 86e0d20..7cee834 100644
--- a/apply.c
+++ b/apply.c@@ -4718,8 +4718,11 @@ int apply_all_patches(struct apply_state *state, if (!strcmp(arg, "-")) { res = apply_patch(state, 0, "<stdin>", options); - if (res < 0) + if (res < 0) { + if (state->lock_file) + rollback_lock_file(state->lock_file); return -1; + } errs |= res; read_stdin = 0; continue;
@@ -4734,16 +4737,22 @@ int apply_all_patches(struct apply_state *state, read_stdin = 0; set_default_whitespace_mode(state); res = apply_patch(state, fd, arg, options); - if (res < 0) + if (res < 0) { + if (state->lock_file) + rollback_lock_file(state->lock_file); return -1; + } errs |= res; close(fd); } set_default_whitespace_mode(state); if (read_stdin) { res = apply_patch(state, 0, "<stdin>", options); - if (res < 0) + if (res < 0) { + if (state->lock_file) + rollback_lock_file(state->lock_file); return -1; + } errs |= res; }
@@ -4757,11 +4766,14 @@ int apply_all_patches(struct apply_state *state, squelched), squelched); } - if (state->ws_error_action == die_on_ws_error) + if (state->ws_error_action == die_on_ws_error) { + if (state->lock_file) + rollback_lock_file(state->lock_file); return error(Q_("%d line adds whitespace errors.", "%d lines add whitespace errors.", state->whitespace_error), state->whitespace_error); + } if (state->applied_after_fixing_ws && state->apply) warning("%d line%s applied after" " fixing whitespace errors.",
--
2.8.1.300.g5fed0c0