🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2408

Re: [PATCH/RFC 1/5] replay: support replaying 2-parent merges

#2408
From: Philippe Blain
Date: Thu, 05 Nov 2026 12:38
117 lines
15485 bytes
Hi Dscho,

> Le 4 nov. 2026 à 21:19, Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com> a écrit :
> From: Johannes Schindelin <johannes.schindelin@gmx.de>

—8<—

> ---
> builtin/history.c         |  16 ++-
> replay.c                  | 209 ++++++++++++++++++++++++++++++++++++--
> t/t3451-history-reword.sh |  21 ++--
> t/t3452-history-split.sh  |   6 +-
> t/t3650-replay-basics.sh  |  46 ++++++++-
> 5 files changed, 269 insertions(+), 29 deletions(-)
> 
> diff --git a/replay.c b/replay.c
> index f96f1f6551..3dbce095f9 100644
> --- a/replay.c
> +++ b/replay.c
> @@ -1,6 +1,7 @@
> #define USE_THE_REPOSITORY_VARIABLE
> 
—8<—

> +/*
> + * Replay a 2-parent merge commit by composing three calls into merge-ort:
> + *
> + *   R = recursive merge of pickme's two original parents (auto-remerge of
> + *       the original merge, accepting any conflicts)
> + *   N = recursive merge of the (possibly rewritten) parents
> + *   O = pickme's tree (the user's actual merge, including any manual
> + *       resolutions)
> + *
> + * The picked tree comes from a non-recursive merge using R as the base,
> + * O as side1 and N as side2. `git diff R O` is morally `git show
> + * --remerge-diff $oldmerge`, so this layers the user's original manual
> + * resolution on top of the freshly auto-merged rewritten parents (see
> + * `replay-design-notes.txt` on the `replay` branch of newren/git).

Maybe we would want to add these design notes as a technical document when this series is out of RFC ? This way we refer to our own documentation. 

—8<—

> @@ -407,17 +550,63 @@ int replay_revisions(struct rev_info *revs,
>    merge_opt.show_rename_progress = 0;
>    last_commit = onto;
>    replayed_commits = kh_init_oid_map();
> +
> +    /*
> +     * Seed the rewritten-commit map with each negative-side ("BOTTOM")
> +     * cmdline entry pointing at `onto`. This matters for merge replay:
> +     * a 2-parent merge whose first parent is the boundary (e.g. the
> +     * commit being reworded) must replay onto the rewritten boundary,
> +     * yet pick_merge_commit uses a self fallback so the second parent
> +     * (a side branch outside the rewrite range) is preserved as-is.
> +     * Pre-seeding the boundary disambiguates the two: in the map ->
> +     * rewritten, missing -> kept as-is.
> +     *
> +     * Only do this for the pick path; revert mode chains reverts
> +     * through last_commit and a pre-seeded boundary would short-circuit
> +     * that chain.
> +     */
> +    if (mode == REPLAY_MODE_PICK) {
> +        for (size_t i = 0; i < revs->cmdline.nr; i++) {
> +            struct rev_cmdline_entry *e = &revs->cmdline.rev[i];
> +            struct commit *boundary;
> +            khint_t pos;
> +            int hr;
> +
> +            if (!(e->flags & BOTTOM))
> +                continue;
> +            boundary = lookup_commit_reference_gently(revs->repo,
> +                                  &e->item->oid, 1);
> +            if (!boundary)
> +                continue;
> +            pos = kh_put_oid_map(replayed_commits,
> +                         boundary->object.oid, &hr);
> +            if (hr != 0)
> +                kh_value(replayed_commits, pos) = onto;
> +        }
> +    }
> +

I understand the intent here, we seed the replayed commit map with onto for the negative revisions, so that a merge with its first parent at the boundary gets its first parent rewritten to onto, but keeps its second parent.  But I think a further tweak is necessary. 

I tried the following: 
- amend the first parent of a merge M (manually, in detached HEAD), changing only the commit message 
- try to replay the merge. Since none of the trees have changed, and the merge-base hasn’t changed, I expect replay to succeed and keep manually resolutions from M. I ran this:

git replay --onto HEAD M^!

and because with this syntax M^2 is a negative revision, it gets mapped to onto, whereas from what I understand it should _not_ be mapped and should be left untouched by replay: the new merge should have M^2 as second parent. 

Since the second parent gets mapped to onto, the merge-base of the replayed merge is changed, so the fast past is skipped,  the new merge conflicts and the replay fails. 

Also, I think this pre-seeding should be mentionned in the commit message. 

Thank you for working on this,and Elijah for prototyping it.  It’s already is a massive time saver for me. 

Philippe. 
Technical Details
Message-ID: <0107772D-4F64-4F24-9E68-C6709AF264EA@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74529-linux-kernel-git=dewy.ru
References: <034ab0f83822e6db67baa423d9fcb753b12b5ac8.1778107405.git.gitgitgadget@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74529-linux-kernel-git=dewy.ru
From: levraiphilippeblain@gmail.com (Philippe Blain)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH/RFC 1/5] replay: support replaying 2-parent merges
Date: Thu, 5 Nov 2026 07:38:08 -0500
Organization: Usenet Network
Message-ID: <0107772D-4F64-4F24-9E68-C6709AF264EA@gmail.com>
References: <034ab0f83822e6db67baa423d9fcb753b12b5ac8.1778107405.git.gitgitgadget@gmail.com>
MIME-Version: 1.0 (1.0)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3638488"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qe9H3ZyRhRKUC6Ny5blCV/ZUlyA= sha256:bwbDIIyvYrPfyCmelsegTKNveEAjzy/GLMNBRcUhuVE=
	sha1:OOgLY13DAVF1rxKZqHtn7mvuFvk= sha256:ShvHC3xASjWr4gvutTMTzL7Gc6I6EFfNxgwOlv7oJ+k=
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 6D0B9112F7B; Thu,  5 Nov 2026 15:45:33 +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 3ppEeurrLsa4;
	Thu,  5 Nov 2026 15:45:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74529-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 58407112F72; Thu,  5 Nov 2026 15:45:19 +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 5AB1534C44; Thu,  5 Nov 2026 12:38:29 +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=1793882303;
	b=sFFxOLRE942J7ai3yVBgxmclxfoXasVcRRpRptrKDWP1p+mu6ZGNSE4Q4INxe+t+WMbS
	 v6DsX55ug8+ssChFDHtPSzB4rtqdBc47CfxjHSTtcnr03I2dALq7v9EKhtpoxhBEPYJu8
	 UdLipACgnymc6LAGlt5UC+5KgUsJnejkV6Hd3pzpoRgkE/pk9EGBHVyPekL/IXHFaBs3G
	 xvbYA6oxhBrrxH+FMG9PhtCD/hrKXx+WU/X9mwErOtFOAk0Xj1K96dxd8H6em+hFD2RNw
	 PXJzbD/zQinMeuWEpA+3LIOOG6W2FtDiBgDIPYGfJzmbPzGqalMDAMeU363FnVp4PJA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793882303;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Content-Type:Content-Transfer-Encoding:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:Mime-Version:Subject:From:In-Reply-To:Cc:Date:
	 Message-Id:References:To:X-Mailer;
	bh=+kBvJsOby6sGUBq0FELD3CzKInFnBdrt5Xfqj1VXRnk=;
	b=Xzp5gpz9RudC7jhT2U1X6pVowTedo1NEQ9v6Svjj1wOyfAL7h//lKW5unt91ZovbYPXf
	 DbecmyyQCEwDExp0AxWaMaVlieJ4od/AAq7OHIWeGZSCWrmHfmbux0jq5KiIOMHtimV/l
	 l9/nlgHmQOnvTSk7Zb33yZgTTDYqKfvyAV2rgnaFJKbIRzjmzvtNnmpCEDAabHnqIQBJs
	 8ZkR+FJVoaves3IUmU3l37RLVKsewCy1GA80sGOelOp63LQjx7w2WgVey+3M2m0h359PW
	 2pw17Oxp4CPBy5oNEgreiazmELSJ4g4Nfz50msHeqpHJi4aAlQoM953Um7hIUDYEQyg==
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=c6AWBdj3;
	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 7EAB6606D802;
	Thu,  5 Nov 2026 12:38:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=c6AWBdj3
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.217.41
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793882302;
	b=eGKeOYmGTtaOU5OpRHrIjFBWNtg1GigxwK8dUKlZsVQKVZGAxgAHuy6pNXVf9Dm3qy3I
	 KxlCJNvE6aFGB1FOr6r8nN+f52esXlbtbX8+dtmO7z1OitSNjEiib6wCMd3ff1ehnxJZu
	 jjk7X/PXeW7Rw0ZmMGo8JpaeJv5OQyNJt+6e96gySZaMwuYpVW6jYvILdAwHhtHK8qX1c
	 yswfgYfbP3A52wROswiw+8NG+MpQjzsnp6N4T+JRtfKP7JmYl2H++vyCoDrTD8uD4WEYZ
	 p9DOTlZt5mkfIC54RhoEgLdfpJmmIX2D1dC2JpTb5uoun2CuwTeEiilwJWGRrACyhiQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793882302;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Content-Type:
	 Content-Transfer-Encoding:Mime-Version:Subject:From:In-Reply-To:Cc:
	 Date:Message-Id:References:To:X-Mailer;
	bh=+kBvJsOby6sGUBq0FELD3CzKInFnBdrt5Xfqj1VXRnk=;
	b=VoOp2E8+7XHHqHnM078XrtgqN37cYKU1M3hUAU1BYEn+7LoKSmFiSYXbLsee+SzzH1vb
	 uGYMpRHdFv07KRjuyHweweGgSPNLhiXimIXeXzMFbA5hWM5jlgXIOaPGMT5gB5FADf4A6
	 eT2tZD2XMnnJW/X6gVTisnGf6WsjjK9kM77DQP9DOqZjfyerjKN7i7evw46lkjGkQ9AVi
	 tDjmOcSjItUr7/5n7C2hYvwcUF0QNAyGLTxv3cpCXZc3f9/cRuKAN/4AtamP/2CBPef0F
	 TwqQoodH/TX15Tc4rOTNj/lVT0Fx4iF5pWHsBNbmKC3xjMXJUEKBEtKgdCjrR3GsWNw==
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=c6AWBdj3;
	arc=none smtp.remote-ip=209.85.217.41
X-Received: from mail-vs1-f41.google.com (mail-vs1-f41.google.com [209.85.217.41])
	(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 46D19606A339
	for <git@vger.kernel.org>; Thu,  5 Nov 2026 12:38:22 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 46D19606A339
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-vs1-f41.google.com with SMTP id ada2fe7eead31-7777fa8f1ccso540227137.3
        for <git@vger.kernel.org>; Thu, 05 Nov 2026 04:38:22 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793882301; x=1794487101; darn=vger.kernel.org;
        h=to:references:message-id:date:cc:in-reply-to:from:subject
         :mime-version:content-transfer-encoding:content-type:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=+kBvJsOby6sGUBq0FELD3CzKInFnBdrt5Xfqj1VXRnk=;
        b=c6AWBdj3oqVYuxhRqMgGqVoHCw+KQl1H/mE7zcdv51n+D2QPBdb/LTTUXUlcjcpXzd
         QRiKAq9US68asC2ItAZ30muRITJzIQ0SEREQ2um6EYWeLdAQQ/xFkw5ccVyXLl+DBgUE
         E4sb5xze2j4np91FULXOMDaEzEGWrkua4i7J06w7saoa+RB+yZ7TMYON4cKxZvI88HXx
         3YK7+CXygDXoJMfnZIKfFs6h+cDD057IybLLJkoeAxqw+VYkh0mnQFTItWR+MotdesUv
         NhzqYlmPo2JMfwPm+bIZnrcwAuxfHnwaViXliio1eeP6PXqil17422RofQy1aP7wf8eT
         RL2w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793882301; x=1794487101;
        h=to:references:message-id:date:cc:in-reply-to:from:subject
         :mime-version:content-transfer-encoding:content-type:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=+kBvJsOby6sGUBq0FELD3CzKInFnBdrt5Xfqj1VXRnk=;
        b=hJstCx1qGsOvrOlk2GsPnsjqiZCc/dW7S6K6rTUSjGt9yNszcXao4PqdGkMfGyjglC
         n0csUyQeJq6zApAq7CPcTvkoOlpCJ3Mlg4Cd3OqrlC3Pnjts9OnpwD0WZQEFK04zfeT5
         XXbKOU5UFiWowQ5U7T+iHpDIVfj/sKaVjFusyV4x4iCo4XTOQQcB3xw3L9oVdVoGQbNC
         DbSsCV6Q/WvW5eDO38o/pDFWVs/k6XJyJe5BTF12SaljHXtsJ4G6ZM3mg6szTJ2ZHACY
         L0DehKKKT5v/j+5jF6wFgRjTFj8G9bSncOxjJaOYa3wQ2vvN7kWaNi4r5ozc7hWmTGd8
         HUug==
X-Gm-Message-State: APuU4Z+8o1wMRZeNotCR9rpmAXJkcx6yAgx9oHnP3Y51Yo0uvGBHkNxl
	zc0BEMSsF0rbwf59zjQVRFMx+iAKtk6M6fxFo+bE+WFvYA40caWjIyiI
X-Gm-Gg: AYBFou32HEQQReQo4f0kG481kjSApHcl6AsuZ5twA0WrbY4fZZ1mh+pcIuzrJT2+z/Y
	SQj9bs62gq4vbDPYUalJMzMWyrsOyUj8RQ3yAlJ66rAwtvSkAYQvVEzFjGwtumsJ1iBxzFQhDiW
	UqVdkics+Wxr5kelxYsydbFFOF7cIrxawZomRA45mtpoL3wvnATqiSKfzvKBanBddYtlBYCcEW4
	SA4qFS1OOskFDvQlakjsQpDCxOjjE6qd//vqggQnMLBpKgTwM9Mrv4jA9swH47zCcKju/tjABpm
	+HHKNtxoD0Zv2QOaVkUg3gQxAGkGgOieYmz6+8asbqil4xOf+262ebyiYWYCYAc6u0kYPWI9uT0
	hRBzqYIY/M1JAFHgl19Ypf1UBSE3IU9DMReVarwkIcu/hV5t85XynK7Y1GhQpV/iUGGbYHIiTzD
	IOdCOu8kLB6BMiG1vwmwX6SjR7DwbdqhWQEYDYC6G4qcdvAQa/k6oRSl9nZkppEBt6kQOXNweIZ
	pe5/74i4DiUQwRw9ZIgp1j7pbGaXz42pZz/dDe/H0q6qpiZia7Cy+CzZzS80s1rHra2JRqEgmYy
	n18eAFYihHh/Zqb91rxW4K9sscWKHs/XUloC15kGeIQB5i7WWloPkw==
X-Received: by 2002:a05:6102:370e:b0:7d0:57e3:d495 with SMTP id ada2fe7eead31-7d07223f476mr7829153137.3.1793882301093;
        Thu, 05 Nov 2026 04:38:21 -0800 (PST)
X-Received: from smtpclient.apple ([204.48.95.75])
        by smtp.gmail.com with ESMTPSA id ada2fe7eead31-7d26fdaf4efsm3808102137.5.2026.11.05.04.38.19
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Thu, 05 Nov 2026 04:38:19 -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-In-Reply-To: <034ab0f83822e6db67baa423d9fcb753b12b5ac8.1778107405.git.gitgitgadget@gmail.com>
X-Cc: git@vger.kernel.org, Elijah Newren <newren@gmail.com>,
 Patrick Steinhardt <ps@pks.im>,
 Johannes Schindelin <Johannes.Schindelin@gmx.de>,
 phillip.wood123@gmail.com
X-Mailer: iPhone Mail (22C152)