From: Junio C Hamano Date: Fri, 5 Feb 2016 22:54:13 +0000 (-0800) Subject: Merge branch 'jk/filter-branch-no-index' into maint X-Git-Tag: v2.7.1~17 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/16f5e2683304b986be49a919198d04652a126271?ds=inline;hp=-c Merge branch 'jk/filter-branch-no-index' into maint 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 --- 16f5e2683304b986be49a919198d04652a126271 diff --combined git-filter-branch.sh index 98f1779cf3,5e094ce18d..86b2ff1e07 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@@ -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 \ @@@ -404,7 -404,7 +404,7 @@@ 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 869e0bf073,97c23c2e31..edb834187a --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@@ -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 && @@@ -418,11 -426,4 +426,11 @@@ test_expect_success 'filter commit mess 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