Commits

Anonymous committed 9035628

filter-branch: Test renaming directories in a tree-filter

This test currently fails.

If b is a directory then 'mv a b' is not a plain "rename", but really a
"move", so we must also test that the directory does not exist with the
old name in the directory with the new name.

There's also some cleanup in the corresponding "rename file" test to avoid
spurious shell syntax errors and "ambigous ref" error from 'git show' (but
these should show up only if the test would fail anyway). Plus we also
test for the non-existence of the old file.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>

Comments (0)

Files changed (1)

t/t7003-filter-branch.sh

 	make_commit B
 	git checkout -b branch B
 	make_commit D
+	mkdir dir
+	make_commit dir/D
 	make_commit E
 	git checkout master
 	make_commit C
 '
 
 test_expect_success 'test that the file was renamed' '
-	test d = $(git show HEAD:doh) &&
+	test d = "$(git show HEAD:doh --)" &&
+	! test -f d &&
 	test -f doh &&
-	test d = $(cat doh)
+	test d = "$(cat doh)"
+'
+
+test_expect_success 'rewrite, renaming a specific directory' '
+	git-filter-branch -f --tree-filter "mv dir diroh || :" HEAD
+'
+
+test_expect_failure 'test that the directory was renamed' '
+	test dir/d = "$(git show HEAD:diroh/d --)" &&
+	! test -d dir &&
+	test -d diroh &&
+	! test -d diroh/dir &&
+	test -f diroh/d &&
+	test dir/d = "$(cat diroh/d)"
 '
 
 git tag oldD HEAD~4