Re: [PATCH] sequencer: reset saved HEAD OID when picking onto an unborn branch
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 24, 2026, 14:54 UTC
- Message-ID
- <xmqqh5h6wa9h.fsf@gitster.g>
- In-Reply-To
- <pull.2317.git.1795242633923.gitgitgadget@gmail.com>
"Wonseok Oh via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 16 quoted lines
> From: Wonseok Oh <marinelay7@gmail.com> > > When picking multiple commits, "git cherry-pick" stores the current HEAD > in .git/sequencer/head for "--abort" to return to. If the branch is > unborn, repo_get_oid() fails and leaves the object ID uninitialized, > but sequencer_pick_revisions() saves it anyway instead of clearing it > to the null OID that sequencer_rollback() checks for to report > "cannot abort from a branch yet to be born". > > As a result, "--abort" errors out with "Could not parse object" in my > master build, while in Debian's 2.47.3 build the uninitialized memory > happened to hold the last picked commit's OID and moved the new branch > there. > > Clear the object ID to the null OID when HEAD cannot be resolved, and > add a test.
As Phillip mentioned, the commit message can use some clarification. In addition to tightening the first paragraph so the relationship between oidclr() and sequencer_rollback() reads clearly, the second paragraph frames the symptoms around anecdotal builds ("in my master build" and "in Debian's 2.47.3 build") instead of describing the general undefined-behavior failure modes. And the final ", and add a test" is filler that does not add much value.
Show 5 quoted lines
> +test_expect_success 'cannot abort a cherry-pick sequence on a new history' ' > + pristine_detach initial && > + git checkout --orphan new_disconnected_seq && > + git reset --hard && > + test_must_fail git cherry-pick base..anotherpick &&
This cherry-pick will fail at the very first step. HEAD stays unborn and the abort-safety file would be empty. Even without the code fix, if the variables on the stack happened to be zero-initialized, doesn't this test pass by coincidence, or fail in rollback_is_safe() with "could not parse abort-safety" rather than "could not parse object"? Perhaps it is a good idea to check how the command fails and with what error message, not just having test_must_fail to make sure that the command dies a controlled death, plus validating that the sequencer/head file stores $ZERO_OID, to harden the test?
Show 10 quoted lines
> + test_must_fail git cherry-pick --abort 2>advice && > + test_grep "cannot abort from a branch yet to be born" advice && > + test_must_fail git rev-parse --verify HEAD > +' > + > test_expect_success 'allow skipping stopped cherry-pick because of untracked file modifications' ' > test_when_finished "rm unrelated" && > pristine_detach initial && > > base-commit: e1ec09b23c8e0deb21a0b95ac5996422277395d4