Skip to content

Commit bf5c057

Browse files
dschogitster
authored andcommitted
sequencer: avoid using errno clobbered by rollback_lock_file()
As pointed out in a review of the `--rebase-merges` patch series, `rollback_lock_file()` clobbers errno. Therefore, we have to report the error message that uses errno before calling said function. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1f1cddd commit bf5c057

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sequencer.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,14 @@ static int write_message(const void *buf, size_t len, const char *filename,
346346
if (msg_fd < 0)
347347
return error_errno(_("could not lock '%s'"), filename);
348348
if (write_in_full(msg_fd, buf, len) < 0) {
349+
error_errno(_("could not write to '%s'"), filename);
349350
rollback_lock_file(&msg_file);
350-
return error_errno(_("could not write to '%s'"), filename);
351+
return -1;
351352
}
352353
if (append_eol && write(msg_fd, "\n", 1) < 0) {
354+
error_errno(_("could not write eol to '%s'"), filename);
353355
rollback_lock_file(&msg_file);
354-
return error_errno(_("could not write eol to '%s'"), filename);
356+
return -1;
355357
}
356358
if (commit_lock_file(&msg_file) < 0)
357359
return error(_("failed to finalize '%s'"), filename);
@@ -2125,9 +2127,9 @@ static int save_head(const char *head)
21252127
written = write_in_full(fd, buf.buf, buf.len);
21262128
strbuf_release(&buf);
21272129
if (written < 0) {
2130+
error_errno(_("could not write to '%s'"), git_path_head_file());
21282131
rollback_lock_file(&head_lock);
2129-
return error_errno(_("could not write to '%s'"),
2130-
git_path_head_file());
2132+
return -1;
21312133
}
21322134
if (commit_lock_file(&head_lock) < 0)
21332135
return error(_("failed to finalize '%s'"), git_path_head_file());

0 commit comments

Comments
 (0)