3 test_description
='help'
8 test_config
help.format html
&&
10 # Unless the path has "://" in it, Git tries to make sure
11 # the documentation directory locally exists. Avoid it as
12 # we are only interested in seeing an attempt to correctly
13 # invoke a help browser in this test.
14 test_config
help.htmlpath
test://html
&&
16 # Name a custom browser
17 test_config browser.
test.cmd .
/test-browser
&&
18 test_config
help.browser
test
21 test_expect_success
"setup" '
22 # Just write out which page gets requested
23 write_script test-browser <<-\EOF
24 echo "$*" >test-browser.log
28 # make sure to exercise these code paths, the output is a bit tricky
30 test_expect_success
'basic help commands' '
31 git help >/dev/null &&
32 git help -a --no-verbose >/dev/null &&
33 git help -g >/dev/null &&
34 git help -a >/dev/null
37 test_expect_success
'invalid usage' '
38 test_expect_code 129 git help -a add &&
39 test_expect_code 129 git help --all add &&
41 test_expect_code 129 git help -g add &&
42 test_expect_code 129 git help -a -c &&
44 test_expect_code 129 git help -g add &&
45 test_expect_code 129 git help -a -g &&
47 test_expect_code 129 git help -g -c &&
48 test_expect_code 129 git help --config-for-completion add &&
49 test_expect_code 129 git help --config-sections-for-completion add
52 for opt
in '-a' '-g' '-c' '--config-for-completion' '--config-sections-for-completion'
54 test_expect_success
"invalid usage of '$opt' with [-i|-m|-w]" '
56 test_expect_code 129 git help $opt -i &&
57 test_expect_code 129 git help $opt -m &&
58 test_expect_code 129 git help $opt -w
62 test_expect_success
"works for commands and guides by default" '
65 echo "test://html/git-status.html" >expect &&
66 test_cmp expect test-browser.log &&
68 echo "test://html/gitrevisions.html" >expect &&
69 test_cmp expect test-browser.log
72 test_expect_success
"--exclude-guides does not work for guides" '
74 test_must_fail git help --exclude-guides revisions &&
75 test_must_be_empty test-browser.log
78 test_expect_success
"--help does not work for guides" "
80 git: 'revisions' is not a git command. See 'git --help'.
82 test_must_fail git revisions --help 2>actual &&
83 test_cmp expect actual
86 test_expect_success
'git help' '
87 git help >help.output &&
88 test_i18ngrep "^ clone " help.output &&
89 test_i18ngrep "^ add " help.output &&
90 test_i18ngrep "^ log " help.output &&
91 test_i18ngrep "^ commit " help.output &&
92 test_i18ngrep "^ fetch " help.output
94 test_expect_success
'git help -g' '
95 git help -g >help.output &&
96 test_i18ngrep "^ attributes " help.output &&
97 test_i18ngrep "^ everyday " help.output &&
98 test_i18ngrep "^ tutorial " help.output
101 test_expect_success
'git help fails for non-existing html pages' '
104 test_must_fail git -c help.htmlpath=html-empty help status &&
105 test_must_be_empty test-browser.log
108 test_expect_success
'git help succeeds without git.html' '
110 mkdir html-with-docs &&
111 touch html-with-docs/git-status.html &&
112 git -c help.htmlpath=html-with-docs help status &&
113 echo "html-with-docs/git-status.html" >expect &&
114 test_cmp expect test-browser.log
117 test_expect_success
'git help -c' '
118 git help -c >help.output &&
119 cat >expect <<-\EOF &&
121 '\''git help config'\'' for more information
124 -e "^[^.]+\.[^.]+$" \
125 -e "^[^.]+\.[^.]+\.[^.]+$" \
126 help.output >actual &&
127 test_cmp expect actual
130 test_expect_success
'git help --config-for-completion' '
131 git help -c >human &&
133 -e "^[^.]+\.[^.]+$" \
134 -e "^[^.]+\.[^.]+\.[^.]+$" human |
135 sed -e "s/\*.*//" -e "s/<.*//" |
136 sort -u >human.munged &&
138 git help --config-for-completion >vars &&
139 test_cmp human.munged vars
142 test_expect_success
'git help --config-sections-for-completion' '
143 git help -c >human &&
145 -e "^[^.]+\.[^.]+$" \
146 -e "^[^.]+\.[^.]+\.[^.]+$" human |
148 sort -u >human.munged &&
150 git help --config-sections-for-completion >sections &&
151 test_cmp human.munged sections
154 test_section_spacing
() {
157 grep -E "(^[^ ]|^$)" out
>actual
160 test_section_spacing_trailer
() {
161 test_section_spacing
"$@" &&
162 test_expect_code
1 git
>out
&&
163 sed -n '/list available subcommands/,$p' <out
>>expect
167 for cmd
in git
"git help"
169 test_expect_success
"'$cmd' section spacing" '
170 test_section_spacing_trailer git help <<-\EOF &&
171 usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
173 These are common Git commands used in various situations:
175 start a working area (see also: git help tutorial)
177 work on the current change (see also: git help everyday)
179 examine the history and state (see also: git help revisions)
181 grow, mark and tweak your common history
183 collaborate (see also: git help workflows)
186 test_cmp expect actual
190 test_expect_success
"'git help -g' section spacing" '
191 test_section_spacing_trailer git help -g <<-\EOF &&
193 The Git concept guides are:
196 test_cmp expect actual
199 test_expect_success
'generate builtin list' '
201 git --list-cmds=builtins >builtins
206 test_expect_success
"$builtin can handle -h" '
208 GIT_CEILING_DIRECTORIES=$(pwd) &&
209 export GIT_CEILING_DIRECTORIES &&
210 test_expect_code 129 git -C sub $builtin -h >output 2>&1
212 test_i18ngrep usage output