1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 05:46:38 +02:00

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>
This commit is contained in:
Johannes Schindelin 2016-10-21 14:26:00 +02:00 committed by Junio C Hamano
parent 452202c74b
commit 4f66c83797

View File

@ -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;
}