aboutsummaryrefslogtreecommitdiffstats
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-08-09 16:18:16 -0700
committerJunio C Hamano <gitster@pobox.com>2023-08-09 16:18:16 -0700
commite8c53ff91282861d4efe5d807129a55e193e6451 (patch)
treeab211df1696719021339b621c31ad26ddd32585d /t/test-lib-functions.sh
parentMerge branch 'ma/locate-in-path-for-windows' (diff)
parentrebase --skip: fix commit message clean up when skipping squash (diff)
downloadgit-e8c53ff91282861d4efe5d807129a55e193e6451.tar.gz
git-e8c53ff91282861d4efe5d807129a55e193e6451.zip
Merge branch 'pw/rebase-skip-commit-message-fix'
"git rebase -i" with a series of squash/fixup, when one of the steps stopped in conflicts and ended up getting skipped, did not handle the accumulated commit log messages, which has been corrected. * pw/rebase-skip-commit-message-fix: rebase --skip: fix commit message clean up when skipping squash
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 2fa716c567..2f8868caa1 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1291,6 +1291,39 @@ test_cmp_rev () {
fi
}
+# Tests that a commit message matches the expected text
+#
+# Usage: test_commit_message <rev> [-m <msg> | <file>]
+#
+# When using "-m" <msg> will have a line feed appended. If the second
+# argument is omitted then the expected message is read from stdin.
+
+test_commit_message () {
+ local msg_file=expect.msg
+
+ case $# in
+ 3)
+ if test "$2" = "-m"
+ then
+ printf "%s\n" "$3" >"$msg_file"
+ else
+ BUG "Usage: test_commit_message <rev> [-m <message> | <file>]"
+ fi
+ ;;
+ 2)
+ msg_file="$2"
+ ;;
+ 1)
+ cat >"$msg_file"
+ ;;
+ *)
+ BUG "Usage: test_commit_message <rev> [-m <message> | <file>]"
+ ;;
+ esac
+ git show --no-patch --pretty=format:%B "$1" -- >actual.msg &&
+ test_cmp "$msg_file" actual.msg
+}
+
# Compare paths respecting core.ignoreCase
test_cmp_fspath () {
if test "x$1" = "x$2"