From: Michele Locati <michele@locati.it>
To: ps@pks.im
Cc: dev@grantmoyer.com, git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] fiter-branch: fix commit map init from state branch
Date: Wed, 30 Sep 2026 22:38:22 +0200 [thread overview]
Message-ID: <20260930203822.958-1-michele@locati.it> (raw)
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
next prev parent reply other threads:[~2026-09-30 20:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-01 3:31 [PATCH] fiter-branch: fix commit map init from state branch Grant Moyer
2026-09-29 14:31 ` Michele Locati
2026-09-30 14:40 ` Patrick Steinhardt
2026-09-30 15:48 ` Grant Moyer
2026-09-30 16:08 ` Patrick Steinhardt
2026-09-30 20:38 ` Michele Locati [this message]
2026-10-01 1:23 ` [PATCH v2] filter-branch: " Grant Moyer
2026-10-01 5:36 ` Patrick Steinhardt
2026-10-01 6:33 ` Michele Locati
2026-10-01 16:10 ` Junio C Hamano
2026-10-03 1:01 ` [PATCH v3] " Grant Moyer
2026-10-05 6:11 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260930203822.958-1-michele@locati.it \
--to=michele@locati.it \
--cc=dev@grantmoyer.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox