🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3622

Re: [PATCH] sequencer: reset saved HEAD OID when picking onto an unborn branch

#3622
From: Phillip Wood
Date: Mon, 23 Nov 2026 14:32
119 lines
16628 bytes
Hi Wonseok

Thanks for working on this. I think that as an immediate fix for the use 
of an uninitialized variable the patch looks good, but I'm not sure the 
behavior of cherry-pick and revert onto an unborn branch makes much sense.

On 21/11/2026 06:30, Wonseok Oh via GitGitGadget wrote:
> 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".

I had a hard time parsing the second half of that sentence. 
sequencer_rollback() expects us to have saved the null OID when HEAD 
points to an unborn branch, but instead we save some random junk because 
we haven't initialized the 'head' variable. The use of an uninitialized 
variable comes from 0f974e2124 (cherry-pick: allow to pick to unborn 
branches, 2016-06-06). Before that commit we refused to cherry-pick onto 
an unborn branch and so did not use 'head' unless it was initialized.

It is rather strange that when sequencer_rollback() rejects an unborn 
branch it refuses to remove the sequencer state so that it is impossible 
to abort a multi-pick cherry-pick started on an unborn branch. It is 
also strange that we will try and revert a single commit onto an unborn 
branch but not multiple commits. 7acaaac275 (revert: allow single-pick 
in the middle of cherry-pick sequence, 2011-12-10) inserted a separate 
code path for single picks before the check for an unborn branch, so 
prior that commit we refused to cherry-pick and revert onto an unborn 
branch regardless of the number of commits. Going further back in 
history, the check for an unborn branch was introduced by 04d3d3cfc4 
(revert: Save data for continuing after conflict resolution, 
2011-08-04). The commit message does not mention a reason for 
introducing that check and therefore changing the behavior but I assume 
it was to avoid having to support aborting to an unborn branch.

It would be nice to either remove the check for an unborn branch when 
reverting multiple commits, or move the check so that it covers single 
picks as well. It would also be good to allow the user to abort when 
cherry-picking onto a unborn branch. Those changes don't need to be part 
of this series though, they can always come later.

I see that rollback_is_safe() expects to see a null OID when picking 
onto an unborn branch, but update_abort_safety_file() writes an empty 
file in that case. We should be consistent about the way we represent an 
unborn branch in the state files. Arguably an empty file is a better way 
of representing an unborn branch because there is no OID.

Thanks

Phillip

> 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.
> 
> Signed-off-by: Wonseok Oh <marinelay7@gmail.com>
> ---
>      sequencer: reset saved HEAD OID when picking onto an unborn branch
> 
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2317%2Fmarinelay%2Fcherry-pick-unborn-abort-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2317/marinelay/cherry-pick-unborn-abort-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/2317
> 
>   sequencer.c                     |  9 ++++++---
>   t/t3510-cherry-pick-sequence.sh | 10 ++++++++++
>   2 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/sequencer.c b/sequencer.c
> index 4a1c0e70b8..20bfe00ba3 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -5788,9 +5788,12 @@ int sequencer_pick_revisions(struct repository *r,
>   		goto out;
>   	}
>   
> -	if (repo_get_oid(r, "HEAD", &oid) && (opts->action == REPLAY_REVERT)) {
> -		res = error(_("can't revert as initial commit"));
> -		goto out;
> +	if (repo_get_oid(r, "HEAD", &oid)) {
> +		if (opts->action == REPLAY_REVERT) {
> +			res = error(_("can't revert as initial commit"));
> +			goto out;
> +		}
> +		oidclr(&oid, r->hash_algo);
>   	}
>   
>   	if (save_head(oid_to_hex(&oid))) {
> diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh
> index 9400ddfc45..75004bba0c 100755
> --- a/t/t3510-cherry-pick-sequence.sh
> +++ b/t/t3510-cherry-pick-sequence.sh
> @@ -269,6 +269,16 @@ test_expect_success 'allow skipping commit but not abort for a new history' '
>   	test_cmp expect advice
>   '
>   
> +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 &&
> +	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
Technical Details
Message-ID: <27abe897-cba1-4561-816a-875c064ab8c0@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76132-linux-kernel-git=dewy.ru
References: <pull.2317.git.1795242633923.gitgitgadget@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76132-linux-kernel-git=dewy.ru
From: phillip.wood123@gmail.com (Phillip Wood)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] sequencer: reset saved HEAD OID when picking onto an
 unborn branch
Date: Mon, 23 Nov 2026 14:32:38 +0000
Organization: Usenet Network
Message-ID: <27abe897-cba1-4561-816a-875c064ab8c0@gmail.com>
References: <pull.2317.git.1795242633923.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="3901852"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:LZV0DYFXSPfDbHpW2JeVHrxLbQY= sha256:OooYNjMbrCYoxZyUPb0Z4NZU/iAs8ugHIv+eAveClU8=
	sha1:J9pVDIRvzjYUHswoNEECi6/XF48= sha256:Sr0R8NEcg9P7NJXzOr5CQQAOgnjKCmTd2DT7Rpe7Duw=
Content-Language: en-US
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1B20C125DBB; Mon, 23 Nov 2026 17:33:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id YLfDxeYkV1nX;
	Mon, 23 Nov 2026 17:32:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76132-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id F2781125DB9; Mon, 23 Nov 2026 17:32:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id E95132B5C4; Mon, 23 Nov 2026 14:32:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795444366;
	b=iYC6zkn0LYizf4fznDle0ds2/z0+yoCtkknQU9hOQFf001ptAK0PofSdemMk1ncj6O69
	 C1SZmA7ACz4LaMTiS6zRsQdSgO+X2KE4Htox1o8l6K60VDnjRv7h6xcBYvltoGctUdpIb
	 gi0HJ3Vp37Hi9yg+mbupW+nr04MVQjmjpanDj0rZSsoCAnT1Dj9WKY+uvFfuns5zZEeay
	 1BycBPKUBsJBruZs1i/WR6eBsHt4g42WNe//Jk+QrTrqTjZxZca7wwqBIFnp51D6u9qnp
	 2rw1UiJHQ1PTjX4rrqqeB0P+UIH/gvD2I+SDiKH3DrXBXtK++T6isU/lca1EQk5ABzg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795444366;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:Message-ID:Date:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:User-Agent:Reply-To:Subject:To:Cc:References:
	 Content-Language:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=ntHfGL+MKGCwJPNG+oFmBqKgw5RmOiZG4fck/Uf1wbw=;
	b=jgUg7iS/STKxfvvmS2BH6O1Oo6d1AHn8O4EaY0RbGZuX+f6TNg651vZI2kAtVcQ+vwbH
	 GRizRKzjQgPYvBd+HyZ5Y91OJNF6B2rumXZTCin31t10oJEdbEATgfoz8HW+k0t/JgGak
	 l0FqdSKlBSL4ONYfhFxmcgCa63L5K35gW73WpEOY5SPIleyX1rBFzmMdp32P9gq1UMGNk
	 SXu2A9xqXpmvbJviNwcfEILDWMz0G12CC63HUxpi+/RX5DG1NXqBMudc/Vx0LC0BUN02y
	 fpcQXPSpc1Wt5f82ziH9c1+OhrUirO+nZ0tCNMyrVKE65CxFnpmujHXHfazSJ94Uyhw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NzTiFJjy;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id C1E2E606A321;
	Mon, 23 Nov 2026 14:32:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NzTiFJjy
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.49
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795444366;
	b=HXo7AbuCMjDf30zhyjhEtnBuJe+hq+a2OgGW2mMg0QS23aCYqw2uAyOzp1Z2SAUTm3gD
	 2uinjgl0csSH4LwgyTVf5Y0vJYw8AJDizhs/5gS5BgbdiVhepT5yobBkFvg2sYd8zkT1p
	 44ZTWfSzG1gh1LzV7eLpojJ+r+iXlZ/UAb5OdxmkEDBCcSeJZig/aRMk8e2gxsbUKiUTm
	 jNH/B0K03jAIK4enpc9h+pfpR2g4gvn65BQFeud5AL97HJGx1diDJwabWsgUsVzeOJAs7
	 A/vOONocSW970LPEKztIcv0xNxGMv6eVa8S/v4kOoJzwENGgMM4ORbSCRnEYC+2Wrrw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795444366;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Message-ID:Date:MIME-Version:User-Agent:Reply-To:Subject:To:Cc:
	 References:Content-Language:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=ntHfGL+MKGCwJPNG+oFmBqKgw5RmOiZG4fck/Uf1wbw=;
	b=2ceBJ4FPDDtkNo28CiXnHRmfhwGXmjLR+RTIfpvmu5yC6lO/fY//O4ZBmAagB34T3MWv
	 8kh7rwPN2JK6//W7ML0SzvE8+k36uEdkBiBFZvt8+LUpLOl35iV6ky3Hethc3iLRIlccA
	 O9VOgN342rkjGq0AL/PGlQuRI6HpxVbym/uKLbUFqFvw2yUi1KtoFNjh0HB71HjZd4Ohh
	 iYSA/pGeEjWPmnC1aMx8f50si5F8cLo3xscCp4qMFe7eQhVnFSuMBtihpctsyjkmhKzIS
	 JXSO5SbstXGkPB8YK3o5RZjiszYS1FywdyDkvOUxYL4s6Yfk3Hlh8148wHkQoAcRjpg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NzTiFJjy;
	arc=none smtp.remote-ip=209.85.218.49
X-Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BC42606A31A
	for <git@vger.kernel.org>; Mon, 23 Nov 2026 14:32:45 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8BC42606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-c4cdc606b47so569875866b.0
        for <git@vger.kernel.org>; Mon, 23 Nov 2026 06:32:45 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795444364; x=1796049164; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:reply-to:user-agent
         :mime-version:date:message-id:from:to:cc:subject:date:message-id
         :reply-to:content-type;
        bh=ntHfGL+MKGCwJPNG+oFmBqKgw5RmOiZG4fck/Uf1wbw=;
        b=NzTiFJjygnptZfDY5jyeUfeOB1L5Ps+32NsReljKf19vGEevFnpy3uuYPsboLQxxa/
         JZjeIZ8AVpyB++sxf1k28yKrGm46w5a81gRnWbbriFv3quCCn7SSmQZ9LVKl2hXsuK17
         n8AvfWTuDowdfq4gfG6T5WihT3mlTK2ATzTltljG7dzKgwvHkH0rmJdEbQA+W8OmgKQo
         EUlLCVxJAvNL6O0EKEyDkoyemFrPFfr8EECBci3SCmjSkyGcLMuFCDUk3iqRWTAtxQ39
         5nEeqPOJ/vr1l8zvJd2DDYSVPk50GrfdgCH2qmdHcZv5LI4s1FPZlkKLWX2rkBS2syZl
         IZSw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795444364; x=1796049164;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:reply-to:user-agent
         :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=ntHfGL+MKGCwJPNG+oFmBqKgw5RmOiZG4fck/Uf1wbw=;
        b=0FlhDcA/tHfxJryTmDaLzHRRH6BTFabxzSZzzQLVPI4icUtE3TZFDtjH+WR0LXrlh9
         6s2FPoZWRp5HGko9aqnXrdhuBdz0vQwKe9SLKQ6AXjp5cQaBcNfbWYOIFcDV+lp4Qkc4
         OWgB5sSsE1d1VX8LYg8jm+4pGB3zD624vTkt+x/yuZyYSNKvhv8Zt6WF+DR7N/dq2ubq
         52PwpySMqVHdGx8Nhi2N0PlbR+W6QMaqMz8w/VXbwX6ya4Mg4yDf9KSdvgCfABbyXx3n
         XU6OcVywoz+lQByPFYnTzi34i7Lft8jQB1t8hjeCCAtsJYzGSqoE3nFK7BbrIlFLzTr9
         CgAQ==
X-Forwarded-Encrypted: i=1; AL+hErFWWZDW3wT+ilaYqI9OwZSbjomz51gZExaBmqJfJvBNVjqWp120SEPGyY/pTrs1Ut4ZPrQ=@vger.kernel.org
X-Gm-Message-State: APuU4Z8NlOuyoJAk15GIsqOBww2nq57O4e8M9kQkQSwJ5gZLxaFOyC/Y
	je2JKgecvRfSwcjf/YicjumDSQ77w6u+lD9gQaN2+Bu4xN2fn6kyn1Dp
X-Gm-Gg: AZFdTZciOSXZE9dU40CMOeKiMVqgGrb76GI8UY3tkJGnxbULNcY5NSOcb1Bz/kMdMsK
	m8PcZifqhIunqX4boPg9Nt0PCDnuUOzZp8FB7DZtf/s6FSKjYhHyAzHcqpjCABDfNFumUI5WYNX
	uHnJQz2EWDtqRaSfzrEbfxsyKErcli9mEU1JdFogqMjJE86mBUJKCbPPQCMTVwy8oRCa0i9ovlQ
	q6+tyJ5cKH3tx2osgW0DFAXC6aB5TNfM0tmUH3iLCcsBeAxdo5JR9wBagUoA803gzU6MSAgwJut
	oAUufclmu26a1/+wWhyOYykdZQ4kzSAhRkakMO36mYhZbic4g/eHGY+cWFxdDxPZa+R218khNJw
	MA9RQayNU0ZYVZRVNxhziulV7MQ8VIduSnDtjM30B+Pz2CLEZDO6AgVQRbe+B3fpTjDyfA2LOh6
	Nfr5ew9LO9jEQww5jPlLC6bF9/aeYb2+6dzn4AYN/JM2wxkQO8raM7FGfAUSRrB30pTWarwk/Kj
	epfLmopTfkZgKY/ooiOXHDbRWP06hpyCwl4KC+hJIxJxYvYTx1W0iGBxhaTi90iv2iJ7r41e36D
	wOwUnr5Wpm3R9yYGLCgvu6es/ln11b30nCY+D3rNAJtS61Aae4vAPWBzw+M9/Nd4WIYhfIpxJlr
	iGJB/Wradtl1RyiieXpsyMyLY84wE
X-Received: by 2002:a17:907:3e15:b0:c51:249f:7331 with SMTP id a640c23a62f3a-c513a3aacc8mr990461766b.1.1795444363685;
        Mon, 23 Nov 2026 06:32:43 -0800 (PST)
X-Received: from ?IPV6:2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f? ([2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f])
        by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513afe01a0sm421909966b.68.2026.11.23.06.32.42
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Mon, 23 Nov 2026 06:32:43 -0800 (PST)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Reply-To: phillip.wood@dunelm.org.uk
X-Cc: Wonseok Oh <wonseok_oh@korea.ac.kr>, Wonseok Oh <marinelay7@gmail.com>
X-In-Reply-To: <pull.2317.git.1795242633923.gitgitgadget@gmail.com>