diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-04-04 14:28:28 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-04-04 14:28:29 -0700 |
| commit | 054ae834a84898bf53d1a6743a7fcbbc8a8031eb (patch) | |
| tree | 649097414227a3d76c90bd29d27ce30b381eeb59 | |
| parent | Merge branch 'ob/rollback-after-commit-lock-failure' (diff) | |
| parent | sequencer: rewrite save_head() in terms of write_message() (diff) | |
| download | git-054ae834a84898bf53d1a6743a7fcbbc8a8031eb.tar.gz git-054ae834a84898bf53d1a6743a7fcbbc8a8031eb.zip | |
Merge branch 'ob/sequencer-save-head-simplify'
Code clean-up.
* ob/sequencer-save-head-simplify:
sequencer: rewrite save_head() in terms of write_message()
| -rw-r--r-- | sequencer.c | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/sequencer.c b/sequencer.c index 2da9b9f890..ca7c228c9f 100644 --- a/sequencer.c +++ b/sequencer.c @@ -3187,25 +3187,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) |
