Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sequencer: roll back lock file if write_message() failed
author
Johannes Schindelin
<johannes.schindelin@gmx.de>
Fri, 21 Oct 2016 12:26:00 +0000
(14:26 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 21 Oct 2016 16:32:35 +0000
(09:32 -0700)
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>
sequencer.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
452202c
)
diff --git
a/sequencer.c
b/sequencer.c
index 745c86f6541053014dddcb1a5774982bbbdc40f5..9fced42dff087c84313185453793614abf07bb15 100644
(file)
--- 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);
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 error(_("Error wrapping up %s."), filename);
+ }
return 0;
}
return 0;
}