* [PATCH] filter-branch: deal with object name vs. pathname ambiguity in tree-filter
@ 2015-11-23 12:23 SZEDER Gábor
2015-11-24 23:38 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: SZEDER Gábor @ 2015-11-23 12:23 UTC (permalink / raw)
To: Jeff King; +Cc: git, SZEDER Gábor
'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>
---
git-filter-branch.sh | 2 +-
t/t7003-filter-branch.sh | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 27c9c54fbd..cefd1452c6 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -349,7 +349,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 \
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 377c648e04..869e0bf073 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -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
--
2.6.3.416.g766831e
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] filter-branch: deal with object name vs. pathname ambiguity in tree-filter
2015-11-23 12:23 [PATCH] filter-branch: deal with object name vs. pathname ambiguity in tree-filter SZEDER Gábor
@ 2015-11-24 23:38 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2015-11-24 23:38 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: git
On Mon, Nov 23, 2015 at 01:23:16PM +0100, SZEDER Gábor wrote:
> '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.
Thanks, looks obviously correct.
-Peff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-24 23:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23 12:23 [PATCH] filter-branch: deal with object name vs. pathname ambiguity in tree-filter SZEDER Gábor
2015-11-24 23:38 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).