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 <michael.barabanov@gmail.com> Acked-by: Ian Campbell <ijc@hellion.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Barabanov committed Jun 25, 2018 at 21:07 UTC 709cfe848ad2312f80e6f4f7a27aa5d23992a0e3
2 files changed +16
git-filter-branch.sh
+1
@@ -360,6 +360,7 @@ while read commit parents; do
360 git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))
361
362 report_progress
363 + test -f "$workdir"/../map/$commit && continue
364
365 case "$filter_subdir" in
366 "")
t/t7003-filter-branch.sh
+15
@@ -107,6 +107,21 @@ test_expect_success 'test that the directory was renamed' '
107 test dir/D = "$(cat diroh/D.t)"
108 '
109
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 +
125 git tag oldD HEAD~4
126 test_expect_success 'rewrite one branch, keeping a side branch' '
127 git branch modD oldD &&