Merge branch 'jk/filter-branch-no-index'
authorJunio C Hamano <gitster@pobox.com>
Fri, 29 Jan 2016 00:10:12 +0000 (16:10 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Jan 2016 00:10:12 +0000 (16:10 -0800)
A recent optimization to filter-branch in v2.7.0 introduced a
regression when --prune-empty filter is used, which has been
corrected.

* jk/filter-branch-no-index:
filter-branch: resolve $commit^{tree} in no-index case

1  2 
git-filter-branch.sh
t/t7003-filter-branch.sh
diff --combined git-filter-branch.sh
index 98f1779cf3241fa12300fbf3dc0c4eff8ab10b61,5e094ce18d9d31fe313e7ccf87ff72da49c8bf39..86b2ff1e07614846465109dcb4b9afed11013839
@@@ -361,7 -361,7 +361,7 @@@ while read commit parents; d
                        die "tree filter failed: $filter_tree"
  
                (
 -                      git diff-index -r --name-only --ignore-submodules $commit &&
 +                      git diff-index -r --name-only --ignore-submodules $commit -- &&
                        git ls-files --others
                ) > "$tempdir"/tree-state || exit
                git update-index --add --replace --remove --stdin \
        then
                tree=$(git write-tree)
        else
-               tree="$commit^{tree}"
+               tree=$(git rev-parse "$commit^{tree}")
        fi
        workdir=$workdir @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
                "$tree" $parentstr < ../message > ../map/$commit ||
diff --combined t/t7003-filter-branch.sh
index 8868e6e090e0528f41e11473e7efee3ca54bd6b3,97c23c2e3180fad8e66365cfb80a4d7fa1e2f6b1..cb8fbd8e5e03a0ff5a176cc947419c357fd65d99
@@@ -333,6 -333,14 +333,14 @@@ test_expect_success 'prune empty collap
        test_cmp expect actual
  '
  
+ test_expect_success 'prune empty works even without index/tree filters' '
+       git rev-list HEAD >expect &&
+       git commit --allow-empty -m empty &&
+       git filter-branch -f --prune-empty HEAD &&
+       git rev-list HEAD >actual &&
+       test_cmp expect actual
+ '
  test_expect_success '--remap-to-ancestor with filename filters' '
        git checkout master &&
        git reset --hard A &&
@@@ -387,7 -395,7 +395,7 @@@ test_expect_success 'setup submodule' 
        git branch original HEAD
  '
  
 -orig_head=`git show-ref --hash --head HEAD`
 +orig_head=$(git show-ref --hash --head HEAD)
  
  test_expect_success 'rewrite submodule with another content' '
        git filter-branch --tree-filter "test -d submod && {
                                         mkdir submod &&
                                         : > submod/file
                                         } || :" HEAD &&
 -      test $orig_head != `git show-ref --hash --head HEAD`
 +      test $orig_head != $(git show-ref --hash --head HEAD)
  '
  
  test_expect_success 'replace submodule revision' '
            "if git ls-files --error-unmatch -- submod > /dev/null 2>&1
             then git update-index --cacheinfo 160000 0123456789012345678901234567890123456789 submod
             fi" HEAD &&
 -      test $orig_head != `git show-ref --hash --head HEAD`
 +      test $orig_head != $(git show-ref --hash --head HEAD)
  '
  
  test_expect_success 'filter commit message without trailing newline' '
        test_cmp expect actual
  '
  
 +test_expect_success 'tree-filter deals with object name vs pathname ambiguity' '
 +      test_when_finished "git reset --hard original" &&
 +      ambiguous=$(git rev-list -1 HEAD) &&
 +      git filter-branch --tree-filter "mv file.t $ambiguous" HEAD^.. &&
 +      git show HEAD:$ambiguous
 +'
 +
  test_done