From d8bd08066db18a4db408ff2957f595592e21c336 Mon Sep 17 00:00:00 2001 From: Charvi Mendiratta Date: Wed, 10 Feb 2021 17:06:48 +0530 Subject: [PATCH] t/t3437: simplify and document the test helpers Let's simplify the test_commit_message() helper function and add comments to the function. This patch also document the working of 'fixup -C' with "amend!" in the test-description. Mentored-by: Christian Couder Mentored-by: Phillip Wood Helped-by: Eric Sunshine Signed-off-by: Charvi Mendiratta Signed-off-by: Junio C Hamano --- t/t3437-rebase-fixup-options.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh index 505211a589..6b464989e9 100755 --- a/t/t3437-rebase-fixup-options.sh +++ b/t/t3437-rebase-fixup-options.sh @@ -9,7 +9,9 @@ This test checks the "fixup [-C|-c]" command of rebase interactive. In addition to amending the contents of the commit, "fixup -C" replaces the original commit message with the message of the fixup commit. "fixup -c" also replaces the original message, but opens the -editor to allow the user to edit the message before committing. +editor to allow the user to edit the message before committing. Similar +to the "fixup" command that works with "fixup!", "fixup -C" works with +"amend!" upon --autosquash. ' . ./test-lib.sh @@ -18,17 +20,19 @@ editor to allow the user to edit the message before committing. EMPTY="" +# test_commit_message -m +# test_commit_message +# Verify that the commit message of matches +# or the content of . test_commit_message () { - rev="$1" && # commit or tag we want to test - file="$2" && # test against the content of a file - git show --no-patch --pretty=format:%B "$rev" >actual-message && - if test "$2" = -m - then - str="$3" && # test against a string - printf "%s\n" "$str" >tmp-expected-message && - file="tmp-expected-message" - fi - test_cmp "$file" actual-message + git show --no-patch --pretty=format:%B "$1" >actual && + case "$2" in + -m) + echo "$3" >expect && + test_cmp expect actual ;; + *) + test_cmp "$2" actual ;; + esac } get_author () {