Skip to content

Commit d691551

Browse files
peffgitster
authored andcommittedJun 5, 2017
t0012: test "-h" with builtins
Since commit 99caeed (Let 'git <command> -h' show usage without a git dir, 2009-11-09), the git wrapper handles "-h" specially, skipping any repository setup but still calling the builtin's cmd_foo() function. This means that every cmd_foo() must be ready to handle this case, but we don't have any systematic tests. This led to "git am -h" being broken for some time without anybody noticing. This patch just tests that "git foo -h" works for every builtin, where we see a 129 exit code (the normal code for our usage() helper), and that the word "usage" appears in the output. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8893fd9 commit d691551

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎t/t0012-help.sh

+12
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,16 @@ test_expect_success "--help does not work for guides" "
4949
test_i18ncmp expect actual
5050
"
5151

52+
test_expect_success 'generate builtin list' '
53+
git --list-builtins >builtins
54+
'
55+
56+
while read builtin
57+
do
58+
test_expect_success "$builtin can handle -h" '
59+
test_expect_code 129 git $builtin -h >output 2>&1 &&
60+
test_i18ngrep usage output
61+
'
62+
done <builtins
63+
5264
test_done

0 commit comments

Comments
 (0)
Please sign in to comment.