From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Karsten Blees" <karsten.blees@gmail.com>,
"Nguyen Thai Ngoc Duy" <pclouds@gmail.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Stefan Beller" <sbeller@google.com>,
"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
"Christian Couder" <chriscool@tuxfamily.org>
Subject: [PATCH 81/83] apply: roll back index in case of error
Date: Sun, 24 Apr 2016 15:39:47 +0200 [thread overview]
Message-ID: <1461505189-16234-2-git-send-email-chriscool@tuxfamily.org> (raw)
In-Reply-To: <1461505189-16234-1-git-send-email-chriscool@tuxfamily.org>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
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
next prev parent reply other threads:[~2016-04-24 13:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-24 13:39 [PATCH 80/83] run-command: make dup_devnull() non static Christian Couder
2016-04-24 13:39 ` Christian Couder [this message]
2016-04-25 16:06 ` [PATCH 81/83] apply: roll back index in case of error Johannes Schindelin
2016-05-02 7:07 ` Johannes Schindelin
2016-05-02 7:18 ` Eric Sunshine
2016-05-03 12:57 ` Christian Couder
2016-04-24 13:39 ` [PATCH 82/83] environment: add set_index_file() Christian Couder
2016-05-03 15:36 ` Junio C Hamano
2016-05-04 11:50 ` Christian Couder
2016-04-24 13:39 ` [PATCH 83/83] builtin/am: use apply api in run_apply() Christian Couder
2016-04-25 15:03 ` Johannes Schindelin
2016-05-05 10:04 ` Christian Couder
2016-04-25 15:05 ` [PATCH 80/83] run-command: make dup_devnull() non static Johannes Schindelin
2016-05-05 9:50 ` Christian Couder
2016-05-05 20:07 ` Johannes Sixt
2016-05-06 13:56 ` Christian Couder
2016-05-06 15:34 ` Johannes Schindelin
2016-05-07 10:12 ` Christian Couder
2016-05-07 12:13 ` Johannes Schindelin
2016-05-07 13:46 ` Christian Couder
2016-05-08 6:33 ` Johannes Schindelin
2016-05-08 10:15 ` Duy Nguyen
2016-05-09 15:05 ` Johannes Schindelin
2016-05-09 17:40 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461505189-16234-2-git-send-email-chriscool@tuxfamily.org \
--to=christian.couder@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=avarab@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karsten.blees@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).