Skip to content

Commit d8bd080

Browse files
charvi-077gitster
authored andcommitted
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 <[email protected]> Mentored-by: Phillip Wood <[email protected]> Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Charvi Mendiratta <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4755fed commit d8bd080

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

t/t3437-rebase-fixup-options.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ This test checks the "fixup [-C|-c]" command of rebase interactive.
99
In addition to amending the contents of the commit, "fixup -C"
1010
replaces the original commit message with the message of the fixup
1111
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.
1315
'
1416

1517
. ./test-lib.sh
@@ -18,17 +20,19 @@ editor to allow the user to edit the message before committing.
1820

1921
EMPTY=""
2022

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>.
2127
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
3236
}
3337

3438
get_author () {

0 commit comments

Comments
 (0)