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

Re: [PATCH] fiter-branch: fix commit map init from state branch

From
Michele Locati <michele@locati.it>
Date
Sep 30, 2026, 20:38 UTC
Message-ID
<20260930203822.958-1-michele@locati.it>
In-Reply-To
<ar0fRtN8XMG-fyis@pks.im>
Hi Patrick,
> Michele, it seems like you have already invested some time into
> reproducing the issue. Can this maybe be put into a proper test case
> that directly exercises your issues (that is, the swapped entries and
> such)?

Sure. The test below performs an incremental rewrite in two runs: the second run must attach the new commit to the parent rewritten by the first run, and the saved state must contain "original:rewritten" entries. Without the fix the new commit is attached to the original parent, and the test fails at test_cmp_rev.

I checked it against master (a018953): it fails without the fix and passes with it, and the other tests of t7003 still pass. It also passes with v2.49.1, the last version before the regression.

Grant, feel free to squash it into your patch.
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -126,6 +126,27 @@ test_expect_success 'using --state-branch to skip already rewritten commits' '
 	test_cmp_rev $W HEAD
 '
 
+test_expect_success '--state-branch incremental rewrite uses the rewritten parents' '
+	git init incremental &&
+	(
+		cd incremental &&
+		mkdir sub &&
+		test_commit first sub/file &&
+		test_commit outside root-file &&
+		git filter-branch --state-branch refs/state \
+			--prune-empty --subdirectory-filter sub -- HEAD &&
+		rewritten_first=$(git rev-parse HEAD) &&
+		git reset --hard outside &&
+		test_commit second sub/file &&
+		git filter-branch -f --state-branch refs/state \
+			--prune-empty --subdirectory-filter sub -- outside..HEAD &&
+		test_cmp_rev $rewritten_first HEAD^ &&
+		git show refs/state:filter.map >map &&
+		echo "$(git rev-parse second):$(git rev-parse HEAD)" >expect &&
+		grep "^$(git rev-parse second):" map >actual &&
+		test_cmp expect actual
+	)
+'
+
 git tag oldD HEAD~4
 test_expect_success 'rewrite one branch, keeping a side branch' '
 	git branch modD oldD &&

Thanks,
Michele
Previous: Patrick SteinhardtNext: Grant Moyer
Message 6 of 12 in “fiter-branch: fix commit map init from state branch”
  1. fiter-branch: fix commit map init from state branchGrant Moyer, Aug 1, 2026
  2. Michele LocatiSep 29, 2026
  3. Patrick SteinhardtSep 30, 2026
  4. Grant MoyerSep 30, 2026
  5. Patrick SteinhardtSep 30, 2026
  6. Michele LocatiSep 30, 2026
  7. filter-branch: fix commit map init from state branchGrant Moyer, Oct 1, 2026
  8. Patrick SteinhardtOct 1, 2026
  9. Michele LocatiOct 1, 2026
  10. Junio C HamanoOct 1, 2026
  11. filter-branch: fix commit map init from state branchGrant Moyer, Oct 3, 2026
  12. Patrick SteinhardtOct 5, 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.