Code

Merge branch 'jc/hide-cr-in-diff-from-less'
[git.git] / t / t7003-filter-branch.sh
index 1639c7aa9624bf3219afd021daf14c6f07dcfc32..b0a9d7d536314ec842b141c09ba0d6f8b06b6288 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-test_description='git-filter-branch'
+test_description='git filter-branch'
 . ./test-lib.sh
 
 make_commit () {
@@ -32,14 +32,22 @@ test_expect_success 'setup' '
 H=$(git rev-parse H)
 
 test_expect_success 'rewrite identically' '
-       git-filter-branch branch
+       git filter-branch branch
 '
 test_expect_success 'result is really identical' '
        test $H = $(git rev-parse HEAD)
 '
 
+test_expect_success 'rewrite bare repository identically' '
+       (git config core.bare true && cd .git && git filter-branch branch)
+'
+git config core.bare false
+test_expect_success 'result is really identical' '
+       test $H = $(git rev-parse HEAD)
+'
+
 test_expect_success 'rewrite, renaming a specific file' '
-       git-filter-branch -f --tree-filter "mv d doh || :" HEAD
+       git filter-branch -f --tree-filter "mv d doh || :" HEAD
 '
 
 test_expect_success 'test that the file was renamed' '
@@ -50,7 +58,7 @@ test_expect_success 'test that the file was renamed' '
 '
 
 test_expect_success 'rewrite, renaming a specific directory' '
-       git-filter-branch -f --tree-filter "mv dir diroh || :" HEAD
+       git filter-branch -f --tree-filter "mv dir diroh || :" HEAD
 '
 
 test_expect_success 'test that the directory was renamed' '
@@ -65,7 +73,7 @@ test_expect_success 'test that the directory was renamed' '
 git tag oldD HEAD~4
 test_expect_success 'rewrite one branch, keeping a side branch' '
        git branch modD oldD &&
-       git-filter-branch -f --tree-filter "mv b boh || :" D..modD
+       git filter-branch -f --tree-filter "mv b boh || :" D..modD
 '
 
 test_expect_success 'common ancestor is still common (unchanged)' '
@@ -88,16 +96,20 @@ test_expect_success 'filter subdirectory only' '
        test_tick &&
        git commit -m "again not subdir" &&
        git branch sub &&
-       git-filter-branch -f --subdirectory-filter subdir refs/heads/sub
+       git branch sub-earlier HEAD~2 &&
+       git filter-branch -f --subdirectory-filter subdir \
+               refs/heads/sub refs/heads/sub-earlier
 '
 
 test_expect_success 'subdirectory filter result looks okay' '
        test 2 = $(git rev-list sub | wc -l) &&
        git show sub:new &&
-       test_must_fail git show sub:subdir
+       test_must_fail git show sub:subdir &&
+       git show sub-earlier:new &&
+       test_must_fail git show sub-earlier:subdir
 '
 
-test_expect_success 'setup and filter history that requires --full-history' '
+test_expect_success 'more setup' '
        git checkout master &&
        mkdir subdir &&
        echo A > subdir/new &&
@@ -107,21 +119,12 @@ test_expect_success 'setup and filter history that requires --full-history' '
        git rm a &&
        test_tick &&
        git commit -m "again subdir on master" &&
-       git merge branch &&
-       git branch sub-master &&
-       git-filter-branch -f --subdirectory-filter subdir sub-master
-'
-
-test_expect_success 'subdirectory filter result looks okay' '
-       test 3 = $(git rev-list -1 --parents sub-master | wc -w) &&
-       git show sub-master^:new &&
-       git show sub-master^2:new &&
-       test_must_fail git show sub:subdir
+       git merge branch
 '
 
 test_expect_success 'use index-filter to move into a subdirectory' '
        git branch directorymoved &&
-       git-filter-branch -f --index-filter \
+       git filter-branch -f --index-filter \
                 "git ls-files -s | sed \"s-\\t-&newsubdir/-\" |
                  GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
                        git update-index --index-info &&
@@ -130,7 +133,7 @@ test_expect_success 'use index-filter to move into a subdirectory' '
 
 test_expect_success 'stops when msg filter fails' '
        old=$(git rev-parse HEAD) &&
-       test_must_fail git-filter-branch -f --msg-filter false HEAD &&
+       test_must_fail git filter-branch -f --msg-filter false HEAD &&
        test $old = $(git rev-parse HEAD) &&
        rm -rf .git-rewrite
 '
@@ -141,7 +144,7 @@ test_expect_success 'author information is preserved' '
        test_tick &&
        GIT_AUTHOR_NAME="B V Uips" git commit -m bvuips &&
        git branch preserved-author &&
-       git-filter-branch -f --msg-filter "cat; \
+       git filter-branch -f --msg-filter "cat; \
                        test \$GIT_COMMIT != $(git rev-parse master) || \
                        echo Hallo" \
                preserved-author &&
@@ -153,7 +156,7 @@ test_expect_success "remove a certain author's commits" '
        test_tick &&
        git commit -m i i &&
        git branch removed-author &&
-       git-filter-branch -f --commit-filter "\
+       git filter-branch -f --commit-filter "\
                if [ \"\$GIT_AUTHOR_NAME\" = \"B V Uips\" ];\
                then\
                        skip_commit \"\$@\";
@@ -224,7 +227,7 @@ test_expect_success 'Tag name filtering retains tag message' '
        git cat-file tag T > expect &&
        git filter-branch -f --tag-name-filter cat &&
        git cat-file tag T > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 faux_gpg_tag='object XXXXXX
@@ -248,7 +251,15 @@ test_expect_success 'Tag name filtering strips gpg signature' '
        echo "$faux_gpg_tag" | sed -e s/XXXXXX/$sha1/ | head -n 6 > expect &&
        git filter-branch -f --tag-name-filter cat &&
        git cat-file tag S > actual &&
-       git diff expect actual
+       test_cmp expect actual
+'
+
+test_expect_success 'Tag name filtering allows slashes in tag names' '
+       git tag -m tag-with-slash X/1 &&
+       git cat-file tag X/1 | sed -e s,X/1,X/2, > expect &&
+       git filter-branch -f --tag-name-filter "echo X/2" &&
+       git cat-file tag X/2 > actual &&
+       test_cmp expect actual
 '
 
 test_done