filter-branch: deal with object name vs. pathname ambiguity in tree-filter

'git filter-branch' fails complaining about an ambiguous argument, if
a tree-filter renames a path and the new pathname happens to match an
existing object name.

After the tree-filter has been applied, 'git filter-branch' looks for
changed paths by running:

  git diff-index -r --name-only --ignore-submodules $commit

which then, because of the lack of disambiguating double-dash, can't
decide whether to treat '$commit' as revision or path and errors out.

Add that disambiguating double-dash after 'git diff-index's revision
argument to make sure that '$commit' is interpreted as a revision.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Jeff King <peff@peff.net>
This commit is contained in:
SZEDER Gábor 2015-11-23 13:23:16 +01:00 коммит произвёл Jeff King
Родитель 5cb2e162d2
Коммит 4d2a3646d1
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -319,7 +319,7 @@ while read commit parents; do
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 \

Просмотреть файл

@ -418,4 +418,11 @@ 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