Skip to content

Commit 676c7e5

Browse files
committed
Merge branch 'mb/filter-branch-optim'
"git filter-branch" when used with the "--state-branch" option still attempted to rewrite the commits whose filtered result is known from the previous attempt (which is recorded on the state branch); the command has been corrected not to waste cycles doing so. * mb/filter-branch-optim: filter-branch: skip commits present on --state-branch
2 parents 36b37af + 709cfe8 commit 676c7e5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

git-filter-branch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ while read commit parents; do
372372
git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))
373373

374374
report_progress
375+
test -f "$workdir"/../map/$commit && continue
375376

376377
case "$filter_subdir" in
377378
"")

t/t7003-filter-branch.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ test_expect_success 'test that the directory was renamed' '
107107
test dir/D = "$(cat diroh/D.t)"
108108
'
109109

110+
V=$(git rev-parse HEAD)
111+
112+
test_expect_success 'populate --state-branch' '
113+
git filter-branch --state-branch state -f --tree-filter "touch file || :" HEAD
114+
'
115+
116+
W=$(git rev-parse HEAD)
117+
118+
test_expect_success 'using --state-branch to skip already rewritten commits' '
119+
test_when_finished git reset --hard $V &&
120+
git reset --hard $V &&
121+
git filter-branch --state-branch state -f --tree-filter "touch file || :" HEAD &&
122+
test_cmp_rev $W HEAD
123+
'
124+
110125
git tag oldD HEAD~4
111126
test_expect_success 'rewrite one branch, keeping a side branch' '
112127
git branch modD oldD &&

0 commit comments

Comments
 (0)