@matheusbsbs / matheus-bagliano / commits / 90356287e6
Fork 0

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>

Johannes Sixt committed Mar 31, 2008 at 09:14 UTC 90356287e65181caeaa821d7476b8865d26bc588
1 file changed +18 -2
t/t7003-filter-branch.sh
+18 -2
@@ -17,6 +17,8 @@ test_expect_success 'setup' '
17 make_commit B
18 git checkout -b branch B
19 make_commit D
20 + mkdir dir
21 + make_commit dir/D
22 make_commit E
23 git checkout master
24 make_commit C
@@ -41,9 +43,23 @@ test_expect_success 'rewrite, renaming a specific file' '
43 '
44
45 test_expect_success 'test that the file was renamed' '
44 - test d = $(git show HEAD:doh) &&
46 + test d = "$(git show HEAD:doh --)" &&
47 + ! test -f d &&
48 test -f doh &&
46 - test d = $(cat doh)
49 + test d = "$(cat doh)"
50 +'
51 +
52 +test_expect_success 'rewrite, renaming a specific directory' '
53 + git-filter-branch -f --tree-filter "mv dir diroh || :" HEAD
54 +'
55 +
56 +test_expect_failure 'test that the directory was renamed' '
57 + test dir/d = "$(git show HEAD:diroh/d --)" &&
58 + ! test -d dir &&
59 + test -d diroh &&
60 + ! test -d diroh/dir &&
61 + test -f diroh/d &&
62 + test dir/d = "$(cat diroh/d)"
63 '
64
65 git tag oldD HEAD~4