Skip to content

Commit 9035628

Browse files
Johannes Sixtgitster
authored andcommitted
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>
1 parent 803d515 commit 9035628

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

t/t7003-filter-branch.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ test_expect_success 'setup' '
1717
make_commit B
1818
git checkout -b branch B
1919
make_commit D
20+
mkdir dir
21+
make_commit dir/D
2022
make_commit E
2123
git checkout master
2224
make_commit C
@@ -41,9 +43,23 @@ test_expect_success 'rewrite, renaming a specific file' '
4143
'
4244

4345
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 &&
4548
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)"
4763
'
4864

4965
git tag oldD HEAD~4

0 commit comments

Comments
 (0)