aboutsummaryrefslogtreecommitdiffstats
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorJiang Xin <worldhello.net@gmail.com>2023-08-16 07:24:56 +0800
committerJiang Xin <worldhello.net@gmail.com>2023-08-16 07:24:56 +0800
commit62a26b36bd9bf76feb6940e2bee732bd62b429f8 (patch)
tree3500be70c7d872566578e3fa324f1a8d1fe796e7 /t/test-lib-functions.sh
parent450f2c9e3e461e4785643730f9c82eb9a64faddd (diff)
parentf1ed9d7dc0e49dc1a044941d821c9d2342313c26 (diff)
downloadgit-62a26b36bd9bf76feb6940e2bee732bd62b429f8.tar.gz
Merge branch 'master' of github.com:git/git
* 'master' of github.com:git/git: (34 commits) Git 2.42-rc2 t4053: avoid writing to unopened pipe t4053: avoid race when killing background processes Git 2.42-rc1 git maintenance: avoid console window in scheduled tasks on Windows win32: add a helper to run `git.exe` without a foreground window t9001: remove excessive GIT_SEND_EMAIL_NOTTY=1 mv: handle lstat() failure correctly parse-options: disallow negating OPTION_SET_INT 0 repack: free geometry struct send-email: avoid creating more than one Term::ReadLine object send-email: drop FakeTerm hack t0040: declare non-tab indentation to be okay in this script advice: handle "rebase" in error_resolve_conflict() A few more topics before -rc1 mailmap: change primary address for Glen Choo gitignore: ignore clangd .cache directory docs: update when `git bisect visualize` uses `gitk` compat/mingw: implement a native locate_in_PATH() run-command: conditionally define locate_in_PATH() ...
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"