{"thread":{"id":"40861","subject":"[PATCH] filter-branch: deal with object name vs. pathname ambiguity in tree-filter","startedAt":"2015-11-23T12:23:16Z","lastAt":"2015-11-24T23:38:13Z","messageCount":2,"participants":["SZEDER Gábor","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"273606","messageId":"1448281396-5049-1-git-send-email-szeder@ira.uka.de","threadId":"40861","inReplyTo":null,"subject":"[PATCH] filter-branch: deal with object name vs. pathname ambiguity in tree-filter","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-11-23T12:23:16Z","receivedAt":"2015-11-23T12:23:16Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"'git filter-branch' fails complaining about an ambiguous argument, if\na tree-filter renames a path and the new pathname happens to match an\nexisting object name.\n\nAfter the tree-filter has been applied, 'git filter-branch' looks for\nchanged paths by running:\n\n  git diff-index -r --name-only --ignore-submodules $commit\n\nwhich then, because of the lack of disambiguating double-dash, can't\ndecide whether to treat '$commit' as revision or path and errors out.\n\nAdd that disambiguating double-dash after 'git diff-index's revision\nargument to make sure that '$commit' is interpreted as a revision.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n git-filter-branch.sh     | 2 +-\n t/t7003-filter-branch.sh | 7 +++++++\n 2 files changed, 8 insertions(+), 1 deletion(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 27c9c54fbd..cefd1452c6 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -349,7 +349,7 @@ while read commit parents; do\n \t\t\tdie \"tree filter failed: $filter_tree\"\n \n \t\t(\n-\t\t\tgit diff-index -r --name-only --ignore-submodules $commit &&\n+\t\t\tgit diff-index -r --name-only --ignore-submodules $commit -- &&\n \t\t\tgit ls-files --others\n \t\t) > \"$tempdir\"/tree-state || exit\n \t\tgit update-index --add --replace --remove --stdin \\\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex 377c648e04..869e0bf073 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -418,4 +418,11 @@ test_expect_success 'filter commit message without trailing newline' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'tree-filter deals with object name vs pathname ambiguity' '\n+\ttest_when_finished \"git reset --hard original\" &&\n+\tambiguous=$(git rev-list -1 HEAD) &&\n+\tgit filter-branch --tree-filter \"mv file.t $ambiguous\" HEAD^.. &&\n+\tgit show HEAD:$ambiguous\n+'\n+\n test_done\n-- \n2.6.3.416.g766831e\n"},{"id":"273675","messageId":"20151124233813.GC13872@sigill.intra.peff.net","threadId":"40861","inReplyTo":"1448281396-5049-1-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH] filter-branch: deal with object name vs. pathname ambiguity in tree-filter","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-11-24T23:38:13Z","receivedAt":"2015-11-24T23:38:13Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Nov 23, 2015 at 01:23:16PM +0100, SZEDER Gábor wrote:\n\n> 'git filter-branch' fails complaining about an ambiguous argument, if\n> a tree-filter renames a path and the new pathname happens to match an\n> existing object name.\n> \n> After the tree-filter has been applied, 'git filter-branch' looks for\n> changed paths by running:\n> \n>   git diff-index -r --name-only --ignore-submodules $commit\n> \n> which then, because of the lack of disambiguating double-dash, can't\n> decide whether to treat '$commit' as revision or path and errors out.\n> \n> Add that disambiguating double-dash after 'git diff-index's revision\n> argument to make sure that '$commit' is interpreted as a revision.\n\nThanks, looks obviously correct.\n\n-Peff\n"}]}