git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Phillip WoodNext: Wonseok Oh via GitGitGadget
Message 5 of 8 in “sequencer: reset saved HEAD OID when picking onto an unborn branch”
  1. sequencer: reset saved HEAD OID when picking onto an unborn branchWonseok Oh via GitGitGadget, Nov 21, 2026
  2. Phillip WoodNov 23, 2026
  3. Wonseok OhNov 24, 2026
  4. Phillip WoodNov 24, 2026
  5. Junio C HamanoNov 24, 2026
  6. 0/2 sequencer: save the null OID for an unborn branchWonseok Oh via GitGitGadget, Nov 25, 2026
  7. 1/2 sequencer: clear saved HEAD OID when picking onto an unborn branchWonseok Oh via GitGitGadget, Nov 25, 2026
  8. 2/2 sequencer: save the null OID in abort-safety on an unborn branchWonseok Oh via GitGitGadget, Nov 25, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.