Skip to content

Commit 054ae83

Browse files
committed
Merge branch 'ob/sequencer-save-head-simplify'
Code clean-up. * ob/sequencer-save-head-simplify: sequencer: rewrite save_head() in terms of write_message()
2 parents 0ee87cd + 54dbd09 commit 054ae83

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

sequencer.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3187,25 +3187,7 @@ static int create_seq_dir(struct repository *r)
31873187

31883188
static int save_head(const char *head)
31893189
{
3190-
struct lock_file head_lock = LOCK_INIT;
3191-
struct strbuf buf = STRBUF_INIT;
3192-
int fd;
3193-
ssize_t written;
3194-
3195-
fd = hold_lock_file_for_update(&head_lock, git_path_head_file(), 0);
3196-
if (fd < 0)
3197-
return error_errno(_("could not lock HEAD"));
3198-
strbuf_addf(&buf, "%s\n", head);
3199-
written = write_in_full(fd, buf.buf, buf.len);
3200-
strbuf_release(&buf);
3201-
if (written < 0) {
3202-
error_errno(_("could not write to '%s'"), git_path_head_file());
3203-
rollback_lock_file(&head_lock);
3204-
return -1;
3205-
}
3206-
if (commit_lock_file(&head_lock) < 0)
3207-
return error(_("failed to finalize '%s'"), git_path_head_file());
3208-
return 0;
3190+
return write_message(head, strlen(head), git_path_head_file(), 1);
32093191
}
32103192

32113193
static int rollback_is_safe(void)

0 commit comments

Comments
 (0)