Skip to content

Commit 350292a

Browse files
Martin Ågrengitster
authored andcommitted
sequencer: do not roll back lockfile unnecessarily
If `commit_lock_file()` or `hold_lock_file_for_update()` fail, there is no need to call `rollback_lock_file()` on the lockfile. It doesn't hurt either, but it does make different callers in this file inconsistent, which might be confusing. While at it, remove a trailing '.' from a recurring error message. Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5790d25 commit 350292a

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

sequencer.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,8 @@ static int write_message(const void *buf, size_t len, const char *filename,
352352
rollback_lock_file(&msg_file);
353353
return error_errno(_("could not write eol to '%s'"), filename);
354354
}
355-
if (commit_lock_file(&msg_file) < 0) {
356-
rollback_lock_file(&msg_file);
357-
return error(_("failed to finalize '%s'."), filename);
358-
}
355+
if (commit_lock_file(&msg_file) < 0)
356+
return error(_("failed to finalize '%s'"), filename);
359357

360358
return 0;
361359
}
@@ -2107,10 +2105,8 @@ static int save_head(const char *head)
21072105
ssize_t written;
21082106

21092107
fd = hold_lock_file_for_update(&head_lock, git_path_head_file(), 0);
2110-
if (fd < 0) {
2111-
rollback_lock_file(&head_lock);
2108+
if (fd < 0)
21122109
return error_errno(_("could not lock HEAD"));
2113-
}
21142110
strbuf_addf(&buf, "%s\n", head);
21152111
written = write_in_full(fd, buf.buf, buf.len);
21162112
strbuf_release(&buf);
@@ -2119,10 +2115,8 @@ static int save_head(const char *head)
21192115
return error_errno(_("could not write to '%s'"),
21202116
git_path_head_file());
21212117
}
2122-
if (commit_lock_file(&head_lock) < 0) {
2123-
rollback_lock_file(&head_lock);
2124-
return error(_("failed to finalize '%s'."), git_path_head_file());
2125-
}
2118+
if (commit_lock_file(&head_lock) < 0)
2119+
return error(_("failed to finalize '%s'"), git_path_head_file());
21262120
return 0;
21272121
}
21282122

@@ -2246,7 +2240,7 @@ static int save_todo(struct todo_list *todo_list, struct replay_opts *opts)
22462240
todo_list->buf.len - offset) < 0)
22472241
return error_errno(_("could not write to '%s'"), todo_path);
22482242
if (commit_lock_file(&todo_lock) < 0)
2249-
return error(_("failed to finalize '%s'."), todo_path);
2243+
return error(_("failed to finalize '%s'"), todo_path);
22502244

22512245
if (is_rebase_i(opts)) {
22522246
const char *done_path = rebase_path_done();

0 commit comments

Comments
 (0)