summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a4049ae)
raw | patch | inline | side by side (parent: a4049ae)
author | Michael Haggerty <mhagger@alum.mit.edu> | |
Thu, 14 Jan 2010 05:54:48 +0000 (06:54 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 14 Jan 2010 08:27:56 +0000 (00:27 -0800) |
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>
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>
t/lib-rebase.sh | patch | blob | history | |
t/t3404-rebase-interactive.sh | patch | blob | history |
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 0db8250c5817a822021af4ceda1780ebddeaa553..2d922ae43cdaac23392f92d5b9b0470b1056b363 100644 (file)
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
# After setting the fake editor with this function, you can
#
-# - override the commit message with $FAKE_COMMIT_MESSAGE,
+# - override the commit message with $FAKE_COMMIT_MESSAGE
# - amend the commit message with $FAKE_COMMIT_AMEND
# - check that non-commit messages have a certain line count with $EXPECT_COUNT
+# - check the commit count in the commit message header with $EXPECT_HEADER_COUNT
# - rewrite a rebase -i script as directed by $FAKE_LINES.
# $FAKE_LINES consists of a sequence of words separated by spaces.
# The following word combinations are possible:
cat >> fake-editor.sh <<\EOF
case "$1" in
*/COMMIT_EDITMSG)
+ test -z "$EXPECT_HEADER_COUNT" ||
+ test "$EXPECT_HEADER_COUNT" = $(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1") ||
+ exit
test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
exit
index d9382e41d31c6f469095eb35e449a46fd2cf3eb5..0335b781a0f4c1584b33326e648e73083edba70f 100755 (executable)
test_tick &&
GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 &&
echo "******************************" &&
- FAKE_LINES="1 squash 2" git rebase -i --onto master HEAD~2 &&
+ FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=two \
+ git rebase -i --onto master HEAD~2 &&
test B = $(cat file7) &&
test $(git rev-parse HEAD^) = $(git rev-parse master)
'
test_expect_success 'multi-squash only fires up editor once' '
base=$(git rev-parse HEAD~4) &&
FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 squash 2 squash 3 squash 4" \
+ EXPECT_HEADER_COUNT=4 \
git rebase -i $base &&
test $base = $(git rev-parse HEAD^) &&
test 1 = $(git show | grep ONCE | wc -l)
git checkout -b multi-fixup E &&
base=$(git rev-parse HEAD~4) &&
FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \
+ EXPECT_HEADER_COUNT=4 \
git rebase -i $base &&
test $base = $(git rev-parse HEAD^) &&
test 1 = $(git show | grep ONCE | wc -l) &&
git checkout -b squash-fixup E &&
base=$(git rev-parse HEAD~4) &&
FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \
+ EXPECT_HEADER_COUNT=4 \
git rebase -i $base &&
git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
test_cmp expect-squash-fixup actual-squash-fixup &&
git commit -m $n
done &&
one=$(git rev-parse HEAD~3) &&
- FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
+ FAKE_LINES="1 squash 3 2" EXPECT_HEADER_COUNT=two \
+ git rebase -i HEAD~3 &&
test $one = $(git rev-parse HEAD~2)
'