Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-10-21 15:26:00 +0300
committerJunio C Hamano <gitster@pobox.com>2016-10-21 19:32:35 +0300
commit4f66c837972a69cc3520e3f7205f44e8833b941a (patch)
tree225a3ef39354a88243fef2c58d957d3f6a2491c9 /sequencer.c
parent452202c74b8af68de054d30643dd74d8fc606d62 (diff)
sequencer: roll back lock file if write_message() failed
There is no need to wait until the atexit() handler kicks in at the end. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sequencer.c b/sequencer.c
index 745c86f654..9fced42dff 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -241,10 +241,14 @@ static int write_message(struct strbuf *msgbuf, const char *filename)
int msg_fd = hold_lock_file_for_update(&msg_file, filename, 0);
if (msg_fd < 0)
return error_errno(_("Could not lock '%s'"), filename);
- if (write_in_full(msg_fd, msgbuf->buf, msgbuf->len) < 0)
- return error_errno(_("Could not write to %s"), filename);
- if (commit_lock_file(&msg_file) < 0)
+ if (write_in_full(msg_fd, msgbuf->buf, msgbuf->len) < 0) {
+ rollback_lock_file(&msg_file);
+ return error_errno(_("Could not write to '%s'"), filename);
+ }
+ if (commit_lock_file(&msg_file) < 0) {
+ rollback_lock_file(&msg_file);
return error(_("Error wrapping up %s."), filename);
+ }
return 0;
}