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 <chriscool@tuxfamily.org> Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Charvi Mendiratta <charvi077@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Charvi Mendiratta committed Feb 10, 2021 at 17:06 UTC d8bd08066db18a4db408ff2957f595592e21c336
1 file changed +15 -11
t/t3437-rebase-fixup-options.sh
+15 -11
@@ -9,7 +9,9 @@ This test checks the "fixup [-C|-c]" command of rebase interactive.
9 In addition to amending the contents of the commit, "fixup -C"
10 replaces the original commit message with the message of the fixup
11 commit. "fixup -c" also replaces the original message, but opens the
12 -editor to allow the user to edit the message before committing.
12 +editor to allow the user to edit the message before committing. Similar
13 +to the "fixup" command that works with "fixup!", "fixup -C" works with
14 +"amend!" upon --autosquash.
15 '
16
17 . ./test-lib.sh
@@ -18,17 +20,19 @@ editor to allow the user to edit the message before committing.
20
21 EMPTY=""
22
23 +# test_commit_message <rev> -m <msg>
24 +# test_commit_message <rev> <path>
25 +# Verify that the commit message of <rev> matches
26 +# <msg> or the content of <path>.
27 test_commit_message () {
22 - rev="$1" && # commit or tag we want to test
23 - file="$2" && # test against the content of a file
24 - git show --no-patch --pretty=format:%B "$rev" >actual-message &&
25 - if test "$2" = -m
26 - then
27 - str="$3" && # test against a string
28 - printf "%s\n" "$str" >tmp-expected-message &&
29 - file="tmp-expected-message"
30 - fi
31 - test_cmp "$file" actual-message
28 + git show --no-patch --pretty=format:%B "$1" >actual &&
29 + case "$2" in
30 + -m)
31 + echo "$3" >expect &&
32 + test_cmp expect actual ;;
33 + *)
34 + test_cmp "$2" actual ;;
35 + esac
36 }
37
38 get_author () {