@matheusbsbs / matheus-bagliano / commits / f6b78c6eb6
Fork 0

filter-branch: add a test for the commit removal example

In the man page, there is an example which describes how to remove single commits (although it keeps the changes which were not reverted in the next non-removed commit). Better make sure that it works as expected. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 3, 2007 at 17:50 UTC f6b78c6eb626d477b252d39ef2801d4670675a2b
1 file changed +35
t/t7003-filter-branch.sh
+35
@@ -107,4 +107,39 @@ test_expect_success 'use index-filter to move into a subdirectory' '
107 mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved &&
108 test -z "$(git diff HEAD directorymoved:newsubdir)"'
109
110 +test_expect_success 'author information is preserved' '
111 + : > i &&
112 + git add i &&
113 + test_tick &&
114 + GIT_AUTHOR_NAME="B V Uips" git commit -m bvuips &&
115 + git-filter-branch --msg-filter "cat; \
116 + test \$GIT_COMMIT = $(git rev-parse master) && \
117 + echo Hallo" \
118 + preserved-author &&
119 + test 1 = $(git rev-list --author="B V Uips" preserved-author | wc -l)
120 +'
121 +
122 +test_expect_success "remove a certain author's commits" '
123 + echo i > i &&
124 + test_tick &&
125 + git commit -m i i &&
126 + git-filter-branch --commit-filter "\
127 + if [ \"\$GIT_AUTHOR_NAME\" = \"B V Uips\" ];\
128 + then\
129 + shift;\
130 + while [ -n \"\$1\" ];\
131 + do\
132 + shift;\
133 + echo \"\$1\";\
134 + shift;\
135 + done;\
136 + else\
137 + git commit-tree \"\$@\";\
138 + fi" removed-author &&
139 + cnt1=$(git rev-list master | wc -l) &&
140 + cnt2=$(git rev-list removed-author | wc -l) &&
141 + test $cnt1 -eq $(($cnt2 + 1)) &&
142 + test 0 = $(git rev-list --author="B V Uips" removed-author | wc -l)
143 +'
144 +
145 test_done