summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2018-02-28 20:07:58 +0100
committerJunio C Hamano <gitster@pobox.com>2018-02-28 11:15:51 -0800
commit350292a1efb38bbcd6255a424df6adbfe78910ac (patch)
tree5bd9c1233580c2d2bfffcfcacebf8906ab3fb0d9
parent5790d25881a60a1c3a780e997a59774e48c2c026 (diff)
downloadgit-ma/roll-back-lockfiles.tar.gz
sequencer: do not roll back lockfile unnecessarilyma/roll-back-lockfiles
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 <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sequencer.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/sequencer.c b/sequencer.c
index bca6922823..548ad997b5 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -352,10 +352,8 @@ static int write_message(const void *buf, size_t len, const char *filename,
rollback_lock_file(&msg_file);
return error_errno(_("could not write eol to '%s'"), filename);
}
- if (commit_lock_file(&msg_file) < 0) {
- rollback_lock_file(&msg_file);
- return error(_("failed to finalize '%s'."), filename);
- }
+ if (commit_lock_file(&msg_file) < 0)
+ return error(_("failed to finalize '%s'"), filename);
return 0;
}
@@ -2107,10 +2105,8 @@ static int save_head(const char *head)
ssize_t written;
fd = hold_lock_file_for_update(&head_lock, git_path_head_file(), 0);
- if (fd < 0) {
- rollback_lock_file(&head_lock);
+ if (fd < 0)
return error_errno(_("could not lock HEAD"));
- }
strbuf_addf(&buf, "%s\n", head);
written = write_in_full(fd, buf.buf, buf.len);
strbuf_release(&buf);
@@ -2119,10 +2115,8 @@ static int save_head(const char *head)
return error_errno(_("could not write to '%s'"),
git_path_head_file());
}
- if (commit_lock_file(&head_lock) < 0) {
- rollback_lock_file(&head_lock);
- return error(_("failed to finalize '%s'."), git_path_head_file());
- }
+ if (commit_lock_file(&head_lock) < 0)
+ return error(_("failed to finalize '%s'"), git_path_head_file());
return 0;
}
@@ -2246,7 +2240,7 @@ static int save_todo(struct todo_list *todo_list, struct replay_opts *opts)
todo_list->buf.len - offset) < 0)
return error_errno(_("could not write to '%s'"), todo_path);
if (commit_lock_file(&todo_lock) < 0)
- return error(_("failed to finalize '%s'."), todo_path);
+ return error(_("failed to finalize '%s'"), todo_path);
if (is_rebase_i(opts)) {
const char *done_path = rebase_path_done();