@matheusbsbs / matheus-bagliano / commits / 959c0d06ea
Fork 0

t3404: Test the commit count in commit messages generated by "rebase -i"

The first line of commit messages generated for "rebase -i" squash/fixup commits includes a count of the number of commits that are being combined. Add machinery to check that this count is correct, and add such a check to some test cases. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Jan 14, 2010 at 06:54 UTC 959c0d06eafd7723517c953e80ee1a60881c373b
2 files changed +12 -3
t/lib-rebase.sh
+5 -1
@@ -2,9 +2,10 @@
2
3 # After setting the fake editor with this function, you can
4 #
5 -# - override the commit message with $FAKE_COMMIT_MESSAGE,
5 +# - override the commit message with $FAKE_COMMIT_MESSAGE
6 # - amend the commit message with $FAKE_COMMIT_AMEND
7 # - check that non-commit messages have a certain line count with $EXPECT_COUNT
8 +# - check the commit count in the commit message header with $EXPECT_HEADER_COUNT
9 # - rewrite a rebase -i script as directed by $FAKE_LINES.
10 # $FAKE_LINES consists of a sequence of words separated by spaces.
11 # The following word combinations are possible:
@@ -25,6 +26,9 @@ set_fake_editor () {
26 cat >> fake-editor.sh <<\EOF
27 case "$1" in
28 */COMMIT_EDITMSG)
29 + test -z "$EXPECT_HEADER_COUNT" ||
30 + test "$EXPECT_HEADER_COUNT" = $(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1") ||
31 + exit
32 test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
33 test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
34 exit
t/t3404-rebase-interactive.sh
+7 -2
@@ -135,7 +135,8 @@ test_expect_success 'squash' '
135 test_tick &&
136 GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 &&
137 echo "******************************" &&
138 - FAKE_LINES="1 squash 2" git rebase -i --onto master HEAD~2 &&
138 + FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=two \
139 + git rebase -i --onto master HEAD~2 &&
140 test B = $(cat file7) &&
141 test $(git rev-parse HEAD^) = $(git rev-parse master)
142 '
@@ -230,6 +231,7 @@ test_expect_success 'verbose flag is heeded, even after --continue' '
231 test_expect_success 'multi-squash only fires up editor once' '
232 base=$(git rev-parse HEAD~4) &&
233 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 squash 2 squash 3 squash 4" \
234 + EXPECT_HEADER_COUNT=4 \
235 git rebase -i $base &&
236 test $base = $(git rev-parse HEAD^) &&
237 test 1 = $(git show | grep ONCE | wc -l)
@@ -239,6 +241,7 @@ test_expect_success 'multi-fixup only fires up editor once' '
241 git checkout -b multi-fixup E &&
242 base=$(git rev-parse HEAD~4) &&
243 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \
244 + EXPECT_HEADER_COUNT=4 \
245 git rebase -i $base &&
246 test $base = $(git rev-parse HEAD^) &&
247 test 1 = $(git show | grep ONCE | wc -l) &&
@@ -258,6 +261,7 @@ test_expect_success 'squash and fixup generate correct log messages' '
261 git checkout -b squash-fixup E &&
262 base=$(git rev-parse HEAD~4) &&
263 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \
264 + EXPECT_HEADER_COUNT=4 \
265 git rebase -i $base &&
266 git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
267 test_cmp expect-squash-fixup actual-squash-fixup &&
@@ -297,7 +301,8 @@ test_expect_success 'squash works as expected' '
301 git commit -m $n
302 done &&
303 one=$(git rev-parse HEAD~3) &&
300 - FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
304 + FAKE_LINES="1 squash 3 2" EXPECT_HEADER_COUNT=two \
305 + git rebase -i HEAD~3 &&
306 test $one = $(git rev-parse HEAD~2)
307 '
308