mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
a3952f8e7c
We check that git.html exists, regardless of the page the user wants to open. Checking whether the requested page exists instead gives us a smoother user experience in two use cases: 1) The requested page doesn't exist When calling a git command and there is an error, most users reasonably expect git to produce an error message on the standard error stream, but in this case we pass the filepath to git web--browse which passes it on to a browser (or a helper program like xdg-open or start that should in turn open a browser) without any error and many GUI based browsers or helpers won't output such a message onto the standard error stream. Especially the helper programs tend to show the corresponding error message in a message box and wait for user input before exiting. This leaves users in interactive console sessions without an error message in their console, without a console prompt and without the help page they expected. 2) git.html is missing for some reason, but the user asked for some other page We currently refuse to show any local html help page when we can't find git.html. Even if the requested help page exists. If we check for the requested page instead, we can show the user all available pages and only error out on those that don't exist. Signed-off-by: Matthias Aßhauer <mha1993@live.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
104 lines
2.7 KiB
Bash
Executable file
104 lines
2.7 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='help'
|
|
|
|
. ./test-lib.sh
|
|
|
|
configure_help () {
|
|
test_config help.format html &&
|
|
|
|
# Unless the path has "://" in it, Git tries to make sure
|
|
# the documentation directory locally exists. Avoid it as
|
|
# we are only interested in seeing an attempt to correctly
|
|
# invoke a help browser in this test.
|
|
test_config help.htmlpath test://html &&
|
|
|
|
# Name a custom browser
|
|
test_config browser.test.cmd ./test-browser &&
|
|
test_config help.browser test
|
|
}
|
|
|
|
test_expect_success "setup" '
|
|
# Just write out which page gets requested
|
|
write_script test-browser <<-\EOF
|
|
echo "$*" >test-browser.log
|
|
EOF
|
|
'
|
|
|
|
# make sure to exercise these code paths, the output is a bit tricky
|
|
# to verify
|
|
test_expect_success 'basic help commands' '
|
|
git help >/dev/null &&
|
|
git help -a --no-verbose >/dev/null &&
|
|
git help -g >/dev/null &&
|
|
git help -a >/dev/null
|
|
'
|
|
|
|
test_expect_success "works for commands and guides by default" '
|
|
configure_help &&
|
|
git help status &&
|
|
echo "test://html/git-status.html" >expect &&
|
|
test_cmp expect test-browser.log &&
|
|
git help revisions &&
|
|
echo "test://html/gitrevisions.html" >expect &&
|
|
test_cmp expect test-browser.log
|
|
'
|
|
|
|
test_expect_success "--exclude-guides does not work for guides" '
|
|
>test-browser.log &&
|
|
test_must_fail git help --exclude-guides revisions &&
|
|
test_must_be_empty test-browser.log
|
|
'
|
|
|
|
test_expect_success "--help does not work for guides" "
|
|
cat <<-EOF >expect &&
|
|
git: 'revisions' is not a git command. See 'git --help'.
|
|
EOF
|
|
test_must_fail git revisions --help 2>actual &&
|
|
test_cmp expect actual
|
|
"
|
|
|
|
test_expect_success 'git help' '
|
|
git help >help.output &&
|
|
test_i18ngrep "^ clone " help.output &&
|
|
test_i18ngrep "^ add " help.output &&
|
|
test_i18ngrep "^ log " help.output &&
|
|
test_i18ngrep "^ commit " help.output &&
|
|
test_i18ngrep "^ fetch " help.output
|
|
'
|
|
test_expect_success 'git help -g' '
|
|
git help -g >help.output &&
|
|
test_i18ngrep "^ attributes " help.output &&
|
|
test_i18ngrep "^ everyday " help.output &&
|
|
test_i18ngrep "^ tutorial " help.output
|
|
'
|
|
|
|
test_expect_success 'git help fails for non-existing html pages' '
|
|
configure_help &&
|
|
mkdir html-empty &&
|
|
test_must_fail git -c help.htmlpath=html-empty help status &&
|
|
test_must_be_empty test-browser.log
|
|
'
|
|
|
|
test_expect_success 'git help succeeds without git.html' '
|
|
configure_help &&
|
|
mkdir html-with-docs &&
|
|
touch html-with-docs/git-status.html &&
|
|
git -c help.htmlpath=html-with-docs help status &&
|
|
echo "html-with-docs/git-status.html" >expect &&
|
|
test_cmp expect test-browser.log
|
|
'
|
|
|
|
test_expect_success 'generate builtin list' '
|
|
git --list-cmds=builtins >builtins
|
|
'
|
|
|
|
while read builtin
|
|
do
|
|
test_expect_success "$builtin can handle -h" '
|
|
test_expect_code 129 git $builtin -h >output 2>&1 &&
|
|
test_i18ngrep usage output
|
|
'
|
|
done <builtins
|
|
|
|
test_done
|