Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>2023-03-23 19:22:35 +0300
committerJunio C Hamano <gitster@pobox.com>2023-03-24 18:02:05 +0300
commit54dbd0933ba9e35a97562bd4224842c3a0362742 (patch)
treeaa283ec108f85f1853abeb1b2eaad8b3c23afd13 /sequencer.c
parent73876f4861cd3d187a4682290ab75c9dccadbc56 (diff)
sequencer: rewrite save_head() in terms of write_message()
Saves some code duplication. Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/sequencer.c b/sequencer.c
index 1c96a75b1e..3ba28a19c1 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3184,25 +3184,7 @@ static int create_seq_dir(struct repository *r)
static int save_head(const char *head)
{
- struct lock_file head_lock = LOCK_INIT;
- struct strbuf buf = STRBUF_INIT;
- int fd;
- ssize_t written;
-
- fd = hold_lock_file_for_update(&head_lock, git_path_head_file(), 0);
- 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);
- if (written < 0) {
- error_errno(_("could not write to '%s'"), git_path_head_file());
- rollback_lock_file(&head_lock);
- return -1;
- }
- if (commit_lock_file(&head_lock) < 0)
- return error(_("failed to finalize '%s'"), git_path_head_file());
- return 0;
+ return write_message(head, strlen(head), git_path_head_file(), 1);
}
static int rollback_is_safe(void)