From: Junio C Hamano Date: Tue, 24 Nov 2026 14:54:02 GMT Subject: Re: [PATCH] sequencer: reset saved HEAD OID when picking onto an unborn branch Message-ID: In-Reply-To: "Wonseok Oh via GitGitGadget" writes: > From: Wonseok Oh > > 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. > +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? > + 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