Merge branch 'js/filter-branch'
authorJunio C Hamano <gitster@pobox.com>
Wed, 2 Apr 2008 18:13:23 +0000 (11:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Apr 2008 18:13:23 +0000 (11:13 -0700)
* js/filter-branch:
filter-branch: Fix renaming a directory in the tree-filter
filter-branch: Test renaming directories in a tree-filter

git-filter-branch.sh
t/t7003-filter-branch.sh
index 22b6ed4a784192bb865dff83731255b1979a1e39..ea59015baa2507fdc8fe77d1c77ebdb2d5db2fa7 100755 (executable)
@@ -281,7 +281,7 @@ while read commit parents; do
                        die "Could not checkout the index"
                # files that $commit removed are now still in the working tree;
                # remove them, else they would be added again
-               git clean -q -f -x
+               git clean -d -q -f -x
                eval "$filter_tree" < /dev/null ||
                        die "tree filter failed: $filter_tree"
 
index 6827249da5182515847d713ae0bb1d23fc58b5c6..efd658adb6d6327863f430b10ab65aa3f112f996 100755 (executable)
@@ -17,6 +17,8 @@ test_expect_success 'setup' '
        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
@@ -41,9 +43,23 @@ test_expect_success 'rewrite, renaming a specific file' '
 '
 
 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_success '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