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

[PATCH v2 2/2] combine-diff: filter the fast scan by the relative prefix

From
MAMuhammed Dilshad A <dilsheddilu123@gmail.com>
Date
Oct 7, 2026, 16:35 UTC
Message-ID
<dbc32586d8ee3b41bb28cd9f6e838658b2206880.1791390459.git.dilsheddilu123@gmail.com>
In-Reply-To
<cover.1791390459.git.dilsheddilu123@gmail.com>

The pairwise scan filters paths by --relative before looking for renames. The fast scan bypasses those callbacks, so it can show changes outside the requested prefix.

Filter the fast scan's paths by the same literal prefix and release the discarded records. Add tests for excluding outside paths and for keeping explicit prefixes with repeated separators literal, as ordinary diff does.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Muhammed Dilshad A <dilsheddilu123@gmail.com>
---
 combine-diff.c           | 18 ++++++++++++++++++
 t/t4038-diff-combined.sh | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)
diff --git a/combine-diff.c b/combine-diff.c
index d615471717..e8a3bd1ee9 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1474,6 +1474,24 @@ static struct combine_diff_path *find_paths_multitree(
 
 	strbuf_release(&base);
 	free(parents_oid);
+
+	/* Match the prefix filtering used by the pairwise scan. */
+	if (opt->prefix) {
+		struct combine_diff_path **tail = &paths;
+
+		while (*tail) {
+			struct combine_diff_path *p = *tail;
+
+			if (starts_with(p->path, opt->prefix)) {
+				tail = &p->next;
+				continue;
+			}
+			*tail = p->next;
+			for (i = 0; i < nparent; i++)
+				free(p->parent[i].path);
+			free(p);
+		}
+	}
 	return paths;
 }
 
diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh
index 21eeb4fbcb..50df3dfb46 100755
--- a/t/t4038-diff-combined.sh
+++ b/t/t4038-diff-combined.sh
@@ -652,4 +652,25 @@ test_expect_success 'combined raw relative diff follows an outside rename source
 	test_cmp expect actual
 '
 
+test_expect_success 'fast combined relative diff excludes outside paths' '
+	ours_oid=$(git -C cross-prefix rev-parse HEAD^:here/file) &&
+	merged_oid=$(git -C cross-prefix rev-parse HEAD:here/file) &&
+	printf "::100644 000000 100644 %s %s %s MA\tfile\tfile\tfile\n" \
+		"$ours_oid" "$ZERO_OID" "$merged_oid" >expect &&
+	git -C cross-prefix diff-tree --no-commit-id -c --raw --no-renames \
+		--combined-all-paths --relative=here/ HEAD >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'combined diff keeps explicit relative prefixes literal' '
+	git -C cross-prefix diff HEAD^ HEAD --relative=here// >actual &&
+	test_must_be_empty actual &&
+	git -C cross-prefix diff-tree --no-commit-id --cc -M \
+		--combined-all-paths --relative=here// HEAD >actual &&
+	test_must_be_empty actual &&
+	git -C cross-prefix diff-tree --no-commit-id --cc --no-renames \
+		--combined-all-paths --relative=here// HEAD >actual &&
+	test_must_be_empty actual
+'
+
 test_done
-- 
2.55.0
Previous: Muhammed Dilshad ANext: Junio C Hamano
Message 5 of 7 in “combine-diff: honor --relative when printing paths”
  1. combine-diff: honor --relative when printing pathsMuhammed Dilshad A, Oct 7, 2026
  2. Junio C HamanoOct 7, 2026
  3. 0/2 combine-diff: honor relative paths consistentlyMuhammed Dilshad A, Oct 7, 2026
  4. 1/2 combine-diff: honor --relative when printing pathsMuhammed Dilshad A, Oct 7, 2026
  5. 2/2 combine-diff: filter the fast scan by the relative prefixMuhammed Dilshad A, Oct 7, 2026
  6. Junio C HamanoOct 7, 2026
  7. Muhammed Dilshad AOct 9, 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.