[PATCH 81/83] apply: roll back index in case of error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]