Merge branch 'mb/filter-branch-optim'
authorJunio C Hamano <gitster@pobox.com>
Wed, 18 Jul 2018 19:20:32 +0000 (12:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Jul 2018 19:20:32 +0000 (12:20 -0700)
"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

git-filter-branch.sh
t/t7003-filter-branch.sh
index ccceaf19a74373bb23b2a2b1aa71b7f0bb909d54..5c5afa2b985e2e524601518bbb8fb8d3c8efda61 100755 (executable)
@@ -372,6 +372,7 @@ while read commit parents; do
        git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))
 
        report_progress
+       test -f "$workdir"/../map/$commit && continue
 
        case "$filter_subdir" in
        "")
index ec4b160ddb9f966044e729f35cc1edfcc79eed14..e23de7d0b5a4da29effb1e59426f857fed0e91e0 100755 (executable)
@@ -107,6 +107,21 @@ test_expect_success 'test that the directory was renamed' '
        test dir/D = "$(cat diroh/D.t)"
 '
 
+V=$(git rev-parse HEAD)
+
+test_expect_success 'populate --state-branch' '
+       git filter-branch --state-branch state -f --tree-filter "touch file || :" HEAD
+'
+
+W=$(git rev-parse HEAD)
+
+test_expect_success 'using --state-branch to skip already rewritten commits' '
+       test_when_finished git reset --hard $V &&
+       git reset --hard $V &&
+       git filter-branch --state-branch state -f --tree-filter "touch file || :" HEAD &&
+       test_cmp_rev $W HEAD
+'
+
 git tag oldD HEAD~4
 test_expect_success 'rewrite one branch, keeping a side branch' '
        git branch modD oldD &&