3 test_description
='git-filter-branch'
7 lower
=$
(echo $1 |
tr A-Z a-z
)
15 test_expect_success
'setup' '
18 git checkout -b branch B
32 test_expect_success
'rewrite identically' '
36 test_expect_success
'result is really identical' '
37 test $H = $(git rev-parse H2)
40 test_expect_success
'rewrite, renaming a specific file' '
41 git-filter-branch --tree-filter "mv d doh || :" H3
44 test_expect_success
'test that the file was renamed' '
45 test d = $(git show H3:doh)
49 test_expect_success
'rewrite one branch, keeping a side branch' '
50 git-filter-branch --tree-filter "mv b boh || :" modD D..oldD
53 test_expect_success
'common ancestor is still common (unchanged)' '
54 test "$(git merge-base modD D)" = "$(git rev-parse B)"
57 test_expect_success
'filter subdirectory only' '
62 git commit -m "subdir" &&
65 git commit -m "not subdir" a &&
66 echo A > subdir/new &&
68 git commit -m "again subdir" subdir/new &&
71 git commit -m "again not subdir" &&
72 git-filter-branch --subdirectory-filter subdir sub
75 test_expect_success
'subdirectory filter result looks okay' '
76 test 2 = $(git rev-list sub | wc -l) &&
81 test_expect_success
'setup and filter history that requires --full-history' '
82 git checkout master &&
84 echo A > subdir/new &&
87 git commit -m "subdir on master" subdir/new &&
90 git commit -m "again subdir on master" &&
92 git-filter-branch --subdirectory-filter subdir sub-master
95 test_expect_success
'subdirectory filter result looks okay' '
96 test 3 = $(git rev-list -1 --parents sub-master | wc -w) &&
97 git show sub-master^:new &&
98 git show sub-master^2:new &&
102 test_expect_success
'use index-filter to move into a subdirectory' '
103 git-filter-branch --index-filter \
104 "git ls-files -s | sed \"s-\\t-&newsubdir/-\" |
105 GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
106 git update-index --index-info &&
107 mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved &&
108 test -z "$(git diff HEAD directorymoved:newsubdir)"'
110 test_expect_success
'stops when msg filter fails' '
111 ! git-filter-branch --msg-filter false nonono &&
112 rm -rf .git-rewrite &&
113 ! git rev-parse nonono
116 test_expect_success
'author information is preserved' '
120 GIT_AUTHOR_NAME="B V Uips" git commit -m bvuips &&
121 git-filter-branch --msg-filter "cat; \
122 test \$GIT_COMMIT != $(git rev-parse master) || \
125 test 1 = $(git rev-list --author="B V Uips" preserved-author | wc -l)
128 test_expect_success
"remove a certain author's commits" '
132 git-filter-branch --commit-filter "\
133 if [ \"\$GIT_AUTHOR_NAME\" = \"B V Uips\" ];\
136 while [ -n \"\$1\" ];\
143 git commit-tree \"\$@\";\
144 fi" removed-author &&
145 cnt1=$(git rev-list master | wc -l) &&
146 cnt2=$(git rev-list removed-author | wc -l) &&
147 test $cnt1 -eq $(($cnt2 + 1)) &&
148 test 0 = $(git rev-list --author="B V Uips" removed-author | wc -l)