diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index fff8093d4..ad24c8d85 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -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 \
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 377c648e0..869e0bf07 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