From: Wonseok Oh via GitGitGadget Date: Wed, 25 Nov 2026 03:23:44 GMT Subject: [PATCH v2 2/2] sequencer: save the null OID in abort-safety on an unborn branch Message-ID: <14e015ba240a661d8cf8b6bdbc4d7093bbc42ad3.1795577024.git.gitgitgadget@gmail.com> In-Reply-To: From: Wonseok Oh On an unborn branch, .git/sequencer/head holds the null OID, but update_abort_safety_file() writes an empty .git/sequencer/abort-safety. Write the null OID there as well so both state files represent an unborn branch the same way, as older versions of Git expect. Suggested-by: Phillip Wood Signed-off-by: Wonseok Oh --- sequencer.c | 7 +++---- t/t3510-cherry-pick-sequence.sh | 11 +++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sequencer.c b/sequencer.c index 20bfe00ba3..e0bfc6305a 100644 --- a/sequencer.c +++ b/sequencer.c @@ -644,10 +644,9 @@ static void update_abort_safety_file(void) if (!file_exists(git_path_seq_dir())) return; - if (!repo_get_oid(the_repository, "HEAD", &head)) - write_file(git_path_abort_safety_file(), "%s", oid_to_hex(&head)); - else - write_file(git_path_abort_safety_file(), "%s", ""); + if (repo_get_oid(the_repository, "HEAD", &head)) + oidclr(&head, the_repository->hash_algo); + write_file(git_path_abort_safety_file(), "%s", oid_to_hex(&head)); } static int fast_forward_to(struct repository *r, diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index d52fda1c54..fb1ce079f8 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -284,6 +284,17 @@ test_expect_success 'cannot abort a cherry-pick sequence started on an unborn br test_cmp expect actual ' +test_expect_success 'unborn branch is saved as the null OID in the sequencer state' ' + pristine_detach initial && + git checkout --orphan new_disconnected_state && + git reset --hard && + test_must_fail git cherry-pick base..anotherpick 2>err && + test_grep "could not apply .* unrelatedpick" err && + echo $ZERO_OID >expect && + test_cmp expect .git/sequencer/head && + test_cmp expect .git/sequencer/abort-safety +' + test_expect_success 'allow skipping stopped cherry-pick because of untracked file modifications' ' test_when_finished "rm unrelated" && pristine_detach initial && -- gitgitgadget