diff --git a/t/README b/t/README index 4252774f86..9a9daaf2af 100644 --- a/t/README +++ b/t/README @@ -945,6 +945,17 @@ see test-lib-functions.sh for the full list and their options. Merges the given rev using the given message. Like test_commit, creates a tag and calls test_tick before committing. + - commit_body + + Print the message body of , i.e. the contents of its commit + object with the header removed. Use this instead of piping + "git cat-file commit" into "sed", which would hide a failure of + the git command. + + Example: + + commit_body HEAD >actual + - test_set_prereq Set a test prerequisite to be used later with test_have_prereq. The diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 809c662124..03bf31d8ef 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1433,6 +1433,14 @@ test_commit_message () { test_cmp "$msg_file" actual.msg } +# Print the message body of a commit +# Usage: commit_body +commit_body () { + git cat-file commit "$1" >.commit && + sed -e "1,/^$/d" .commit && + rm -f .commit +} + # Compare paths respecting core.ignoreCase test_cmp_fspath () { if test "x$1" = "x$2"