From: "Martin Ågren" <martin.agren@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [PATCH 5/5] sequencer: do not roll back lockfile unnecessarily
Date: Tue, 27 Feb 2018 22:30:13 +0100 [thread overview]
Message-ID: <d1dbf0b0a4742d8afeabd3acb0848e679c88eb50.1519763396.git.martin.agren@gmail.com> (raw)
In-Reply-To: <cover.1519763396.git.martin.agren@gmail.com>
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>
---
sequencer.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index e6bac4692a..0e6d04e4ce 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -303,10 +303,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;
}
@@ -1585,10 +1583,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);
@@ -1597,10 +1593,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;
}
@@ -1724,7 +1718,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();
--
2.16.2.246.ga4ee44448f
next prev parent reply other threads:[~2018-02-27 21:31 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 21:30 [PATCH 0/5] roll back locks in various code paths Martin Ågren
2018-02-27 21:30 ` [PATCH 1/5] sequencer: make lockfiles non-static Martin Ågren
2018-02-27 21:30 ` [PATCH 2/5] sequencer: always roll back lock in `do_recursive_merge()` Martin Ågren
2018-02-27 21:44 ` Jeff King
2018-02-27 22:08 ` Martin Ågren
2018-02-27 22:15 ` Jeff King
2018-02-27 21:30 ` [PATCH 3/5] merge-recursive: always roll back lock in `merge_recursive_generic()` Martin Ågren
2018-02-28 11:02 ` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 0/5] roll back locks in various code paths Martin Ågren
2018-02-28 19:07 ` [PATCH v2 1/5] sequencer: make lockfiles non-static Martin Ågren
2018-02-28 19:07 ` [PATCH v2 2/5] sequencer: always roll back lock in `do_recursive_merge()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 3/5] merge-recursive: always roll back lock in `merge_recursive_generic()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 4/5] merge: always roll back lock in `checkout_fast_forward()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 5/5] sequencer: do not roll back lockfile unnecessarily Martin Ågren
2018-02-28 19:58 ` [PATCH v2 0/5] roll back locks in various code paths Martin Ågren
2018-02-28 23:20 ` Junio C Hamano
2018-03-01 6:18 ` Martin Ågren
2018-03-01 7:41 ` Jeff King
2018-03-01 19:24 ` Junio C Hamano
2018-03-01 20:40 ` Martin Ågren
2018-03-02 10:49 ` Jeff King
2018-03-01 7:38 ` Jeff King
2018-02-27 21:30 ` [PATCH 4/5] merge: always roll back lock in `checkout_fast_forward()` Martin Ågren
2018-02-27 21:30 ` Martin Ågren [this message]
2018-02-27 21:47 ` [PATCH 0/5] roll back locks in various code paths Jeff King
2018-02-27 23:42 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d1dbf0b0a4742d8afeabd3acb0848e679c88eb50.1519763396.git.martin.agren@gmail.com \
--to=martin.agren@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).