Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Wonseok Oh via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Wonseok Oh <wonseok_oh@korea.ac.kr>,
	 Wonseok Oh <marinelay7@gmail.com>
Subject: Re: [PATCH] sequencer: reset saved HEAD OID when picking onto an unborn branch
Date: Tue, 24 Nov 2026 06:54:02 -0800	[thread overview]
Message-ID: <xmqqh5h6wa9h.fsf@gitster.g> (raw)
In-Reply-To: <pull.2317.git.1795242633923.gitgitgadget@gmail.com> (Wonseok Oh via GitGitGadget's message of "Sat, 21 Nov 2026 06:30:33 +0000")

"Wonseok Oh via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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.

> +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

  parent reply	other threads:[~2026-11-24 14:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  6:30 [PATCH] sequencer: reset saved HEAD OID when picking onto an unborn branch Wonseok Oh via GitGitGadget
2026-11-23 14:32 ` Phillip Wood
2026-11-24  2:33   ` Wonseok Oh
2026-11-24 10:41     ` Phillip Wood
2026-11-24 14:54 ` Junio C Hamano [this message]
2026-11-25  3:23 ` [PATCH v2 0/2] sequencer: save the null OID for " Wonseok Oh via GitGitGadget
2026-11-25  3:23   ` [PATCH v2 1/2] sequencer: clear saved HEAD OID when picking onto " Wonseok Oh via GitGitGadget
2026-11-25 16:57     ` Junio C Hamano
2026-11-25  3:23   ` [PATCH v2 2/2] sequencer: save the null OID in abort-safety on " Wonseok Oh via GitGitGadget
2026-11-25 17:07     ` Junio C Hamano
2026-11-26 16:32       ` Phillip Wood
2026-11-25 17:17   ` [PATCH v2 0/2] sequencer: save the null OID for " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqh5h6wa9h.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=marinelay7@gmail.com \
    --cc=wonseok_oh@korea.ac.kr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox