🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #1186

[PATCH v3 1/4] t4219: test more --follow cases across merges

#1186
From: Miklos Vajna
Date: Thu, 22 Oct 2026 20:45
139 lines
13365 bytes
A later commit in this series will speed up 'git log --follow' for
merge commits. Add tests for cases which already work, but had no
test coverage, so it's easy to break them while optimizing:

- --follow through a fork with renames on both sides, with -c, --cc
  and --remerge-diff
- a --no-ff merge taking a rename from the second parent, in both commit
  orders, since the result could depend on the walk order
- a merge keeping the path, while the other side renamed it

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
---
 t/t4219-log-follow-merge.sh | 112 ++++++++++++++++++++++++++++++++++++
 1 file changed, 112 insertions(+)

diff --git a/t/t4219-log-follow-merge.sh b/t/t4219-log-follow-merge.sh
index e370f82955..9616ac64ed 100755
--- a/t/t4219-log-follow-merge.sh
+++ b/t/t4219-log-follow-merge.sh
@@ -126,4 +126,116 @@ test_expect_success '--follow follows renames through a fork in a single history
 	test_cmp expect actual.sorted
 '
 
+for opt in -c --cc --remerge-diff
+do
+	test_expect_success "--follow follows renames through a fork with $opt" '
+		git -C diamond log --follow $opt --pretty=tformat:%s path >log &&
+		grep "^[A-Z]: " log | sort >actual &&
+		cat >expect <<-\EOF &&
+		A: add path0
+		B: modify path0 on upper
+		C: modify path0 on lower
+		M: merge with rename to path
+		X: rename path0 to path1
+		Y: rename path0 to path2
+		Z: modify path
+		EOF
+		test_cmp expect actual
+	'
+done
+
+# Build a merge that takes the renamed path from the second parent, while the
+# first parent only has the old path. $2 decides which side is committed first,
+# which decides the walk order.
+setup_rename_on_second_parent () {
+	git init $1 &&
+	printf "line 1\nline 2\nline 3\nline 4\nline 5\n" >$1/old &&
+	git -C $1 add old &&
+	test_tick &&
+	git -C $1 commit -m "A: add old" &&
+	printf "line 1\nline 2\nline 3 modified\nline 4\nline 5\n" >$1/old &&
+	test_tick &&
+	git -C $1 commit -am "B: modify old" &&
+	git -C $1 branch topic &&
+
+	if test "$2" = topic-first
+	then
+		git -C $1 checkout topic &&
+		git -C $1 mv old new &&
+		test_tick &&
+		git -C $1 commit -m "R: rename old to new" &&
+		git -C $1 checkout master
+	fi &&
+
+	echo other >$1/other &&
+	git -C $1 add other &&
+	test_tick &&
+	git -C $1 commit -m "M: unrelated change on master" &&
+
+	if test "$2" = master-first
+	then
+		git -C $1 checkout topic &&
+		git -C $1 mv old new &&
+		test_tick &&
+		git -C $1 commit -m "R: rename old to new" &&
+		git -C $1 checkout master
+	fi &&
+
+	test_tick &&
+	git -C $1 merge --no-ff -m "merge topic" topic
+}
+
+test_expect_success 'setup merge taking a rename from the second parent' '
+	setup_rename_on_second_parent rename-master-first master-first &&
+	setup_rename_on_second_parent rename-topic-first topic-first
+'
+
+for order in master-first topic-first
+do
+	test_expect_success "--follow follows a rename from the second parent ($order)" '
+		git -C rename-$order log --follow --pretty=tformat:%s new >actual &&
+		cat >expect <<-\EOF &&
+		R: rename old to new
+		B: modify old
+		A: add old
+		EOF
+		test_cmp expect actual
+	'
+done
+
+test_expect_success 'setup merge keeping the path, other side renamed it' '
+	git init keep &&
+	printf "line 1\nline 2\nline 3\nline 4\nline 5\n" >keep/F &&
+	git -C keep add F &&
+	test_tick &&
+	git -C keep commit -m "O: add F" &&
+	git -C keep branch B &&
+	printf "line 1\nline 2\nline 3 A\nline 4\nline 5\n" >keep/F &&
+	test_tick &&
+	git -C keep commit -am "A1: update F in place" &&
+
+	git -C keep checkout B &&
+	git -C keep mv F G &&
+	test_tick &&
+	git -C keep commit -m "B1: rename F to G" &&
+	printf "line 1\nline 2\nline 3\nline 4 B\nline 5\n" >keep/G &&
+	test_tick &&
+	git -C keep commit -am "B2: update G" &&
+
+	git -C keep checkout master &&
+	test_tick &&
+	git -C keep merge -s ours -m "M: merge B, keep F, drop G" B
+'
+
+test_expect_success '--follow follows a rename on the side the merge did not take' '
+	git -C keep log --follow --pretty=tformat:%s F >actual &&
+	cat >expect <<-\EOF &&
+	B2: update G
+	B1: rename F to G
+	A1: update F in place
+	O: add F
+	EOF
+	test_cmp expect actual
+'
+
 test_done
-- 
2.56.0
Technical Details
Message-ID: <704c6df3ff82ae6a686200fd6df09c41b39619ce.1792701579.git.vmiklos@collabora.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-72893-linux-kernel-git=dewy.ru
References: <cover.1792701579.git.vmiklos@collabora.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-72893-linux-kernel-git=dewy.ru
From: vmiklos@collabora.com (Miklos Vajna)
Newsgroups: linux.kernel.git
Subject: [PATCH v3 1/4] t4219: test more --follow cases across merges
Date: Thu, 22 Oct 2026 22:45:48 +0200
Organization: Usenet Network
Message-ID: <704c6df3ff82ae6a686200fd6df09c41b39619ce.1792701579.git.vmiklos@collabora.com>
References: <cover.1792701579.git.vmiklos@collabora.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="327947"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cMRFBx3p8HVOzajBfwcPWcewFe4= sha256:3UWQG3lwcfDsUfRNLp6tQDHR9SO0o1iWEeRAYfHZ0Oc=
	sha1:jW93qqxxPtNHWwQKYv7xPIE/mtU= sha256:VCnYLLDikHq6VABc8qTm+ugUbxriiKksjEI2fOzzjqE=
Content-Disposition: inline
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 4A452111371; Thu, 22 Oct 2026 23:47:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	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 (1024-bit key)
	header.d=collabora.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 hk0fi51EdZCi;
	Thu, 22 Oct 2026 23:47:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-72893-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=collabora.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 88055111360; Thu, 22 Oct 2026 23:47:21 +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 0A16338649; Thu, 22 Oct 2026 20:46:04 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792701963;
	b=Tqu1RTg9bCVEcCYgOkArYuAUDbnM0h2Vz2V7nlvO7dImpxtt51uLrVMMcjgURqbX6dyP
	 VK6p0rPgF/G9zUqEwlZJVGxpj2hIZiOVzRvyXWLSb1Yn8CpNtYsXIS23i66FsbnRRFiwC
	 0h7R3QqqVeeRg9Wm0SeVBsYSck4PvPLraUmRPf2KZKcAXTcwUS+gIVjXToswYu9t4LLvH
	 Y9Kti++ASOQJ/nDcGgoulFBYsMeCQQwvdTb54HiVnp85iA8cRVw9Cpoc/Q90+Dz7x+hLV
	 H66RuFSUgfJiSp+mJWkkC0dY9sh7GmjBqe3ldPRMj+o34yF2lb8gzNzFyB3pMB2KVyw==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792701963;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date:
	 From:To:Cc:Subject:Message-ID:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To:
	 X-Zoho-Virus-Status:X-Zoho-AV-Stamp:X-ZohoMailClient;
	bh=sYUuJIOi0Comm7VnXbt8BvIwOfv/SeFhqTW1aakSuQ4=;
	b=DJWp0oybXmtZSb9k3eK/BWgg+/Le1YJI9gIRkp6j9xVHZsrQgtXFIlc58hlQK9p4XBsY
	 N2FZrHCP/cV5WaGWHdinvmdhMP9FXUD4W8AgamGdIGwOb7rRjmB9NmgIL8hMWn2UO/klX
	 LxoodO9YB34gErPjEJlmnY8+/BNeiaDXq3GegJPcpAiAT4sRh5YMa9raAbuE5euUXMyVi
	 FN7XZGesdmenpQimzbK9yWD7UUT3L4jpTGFCvfvvKxbV1KrNAUESVhXpOLQVmfH2XJUL/
	 ai2Hnh0XGCUDnfuAQ8YuEat4ewUflCzUqXqHkLHlr4j3uPVV5UKb5iLZdNDKEi1F6jw==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=collabora.com header.i=vmiklos@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=Ngv8L1KO;
	dmarc=pass header.from=collabora.com;
	spf=pass smtp.mailfrom=collabora.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 D2FA6606A320;
	Thu, 22 Oct 2026 20:46:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=collabora.com header.i=vmiklos@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=Ngv8L1KO
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.12
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792701963;
	b=qlU6m72IBz77SC0GYV+6ZfTrwATwb73M0V1Tu+VjfM7mIRgYE6uq9B1UsVqwkOLSlhlk
	 24FmdSVzJtrscGdRv/nAguijTF+ti+uee7FT9UmWx0GndEcPeBYvca9nJRNaAniqBKdoM
	 GGw2BUf34TZaXr3V0jCrhJX+1iR3TsI8oJXlu8Pji7mxD2h/I7Rwam1yMljxvvrkhZTTH
	 EL/RkMs+qJPaIZduGSzngWSIrxL4D99V88ZFRgLFlgM0VBghT/Fkgei085gEZdX+f/w/z
	 WjZfXC/SZ4ixX6/h9SfiF+5IYqszt4Dn6KBE71FKzlZjGcDsPXsmNQw97aVfgxQWt1A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792701963;
	h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject:
	 Message-ID:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:
	 X-Zoho-Virus-Status:X-Zoho-AV-Stamp:X-ZohoMailClient;
	bh=sYUuJIOi0Comm7VnXbt8BvIwOfv/SeFhqTW1aakSuQ4=;
	b=E1DQoLoIMqZ8wbDp9QjS/ArhJB65nI+LFFRZRGUQCiEeyNt6b0zyNLNs+YpHp9KcFAO7
	 URs+/tZY2U3JOqV8ivMyg0m5AH2aOMzcgiKqCRpuYyAjsOjLjnfljQIXGU67zJPOfDA8M
	 ivTFnLS8AVk5heNz99EUOWwNgs86uUvJ13bM5TlN2p73/ZyvFnEOpQG9KEVw6lo3xoOFo
	 50toUKAEqdp8w6wkxNYiZqjJEcd2SuMx+f0+FeivTHbbhuSpYfPIE4DL+xRsEQ0Etgc1B
	 1ViMikLPr/rv2IjGtmVJnWN7QDcdIFkIaFVNOpG31u2NLtonfAn8biRIbWMN5pwHCww==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=pass header.from=collabora.com;
	spf=pass smtp.mailfrom=collabora.com;
	dkim=pass header.d=collabora.com header.i=vmiklos@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=Ngv8L1KO;
	arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.12
X-Received: from sender5-op-o12.zoho.com (sender5-op-o12.zoho.com [165.173.182.12])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 849FC606A319
	for <git@vger.kernel.org>; Thu, 22 Oct 2026 20:46:02 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 849FC606A319
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com
X-ARC-Seal: i=1; a=rsa-sha256; t=1792701954; cv=none; 
	d=zohomail.com; s=zohoarc; 
	b=cYdjjpFouaIzCLk/nS5kAo7Ibgfx65G3NWzxxrLg9wLu+neTzuJJ0FUGysCwOy1rTu03BSFVsxrHoj4BJxo66WwLyEyTpO8hRKPrBq9IwZtUBla5fob0m66T3pDqb1I+B4d7Lk12PfK1Oph8EYP9QaApoFj/XRRa6CgPRxU1JX0=
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; 
	t=1792701954; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; 
	bh=sYUuJIOi0Comm7VnXbt8BvIwOfv/SeFhqTW1aakSuQ4=; 
	b=fNfQi9OgPlRJ6pWCF1usnNqDg1/quZf3TquTX4/n3C21jKJyCM3WY2doGGlXSs56hWnt6Bs2YI4bqJXHbcg+fV+8fuqysy6W5CYOXlg+CNiZafupM1Pt4eQ/+viBfgHGh82neytA+kJC2wJqvAXEfpjNESGJvFasshc6MZ5VOAI=
X-ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass  header.i=collabora.com;
	spf=pass  smtp.mailfrom=vmiklos@collabora.com;
	dmarc=pass header.from=<vmiklos@collabora.com>
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1792701954;
	s=zohomail; d=collabora.com; i=vmiklos@collabora.com;
	h=Date:Date:From:From:To:To:Cc:Cc:Subject:Subject:Message-ID:MIME-Version:Content-Type:In-Reply-To:Message-Id:Reply-To;
	bh=sYUuJIOi0Comm7VnXbt8BvIwOfv/SeFhqTW1aakSuQ4=;
	b=Ngv8L1KOjUlbpm0fyAscVPPx7p/k2wBB9/dG8myvO3lZnXqeWjJRgqwd1u3jwwIR
	ni/ADFcr++cHKWl5KHSgFsPVUXGjrJ4el1LCT0ttpoXvAzWTN87rgpJCMf8v19Djgl5
	MxJov9S6J14VTzoKcrM1201TDnKlMqxJ4fEZiIPU=
X-Received: by smtp.zohomail.com with SMTPS id 1792701952570835.3199616441486;
	Thu, 22 Oct 2026 13:45:52 -0700 (PDT)
X-Cc: szeder.dev@gmail.com, ps@pks.im, git@vger.kernel.org
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: <cover.1792701579.git.vmiklos@collabora.com>
X-Zoho-Virus-Status: 1
X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/292.682.56
X-ZohoMailClient: External