Skip to content

Commit 709cfe8

Browse files
mbarabangitster
authored andcommitted
filter-branch: skip commits present on --state-branch
The commits in state:filter.map have already been processed, so don't filter them again. This makes incremental git filter-branch much faster. Also add tests for --state-branch option. Signed-off-by: Michael Barabanov <[email protected]> Acked-by: Ian Campbell <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fc54c1a commit 709cfe8

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
@@ -360,6 +360,7 @@ while read commit parents; do
360360
git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))
361361

362362
report_progress
363+
test -f "$workdir"/../map/$commit && continue
363364

364365
case "$filter_subdir" in
365366
"")

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)