]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t0012-help.sh
Merge branch 'mk/doc-gitfile-more' into maint-2.43
[thirdparty/git.git] / t / t0012-help.sh
index 91b68c74a154a97c50f1011ebf5ec70c2ce66a33..1d273d91c2125ae2c16ae1a14c628cf23fcecc06 100755 (executable)
@@ -35,17 +35,45 @@ test_expect_success 'basic help commands' '
 '
 
 test_expect_success 'invalid usage' '
+       test_expect_code 129 git help -a add &&
+       test_expect_code 129 git help --all add &&
+
        test_expect_code 129 git help -g add &&
        test_expect_code 129 git help -a -c &&
 
        test_expect_code 129 git help -g add &&
        test_expect_code 129 git help -a -g &&
 
+       test_expect_code 129 git help --user-interfaces add &&
+
        test_expect_code 129 git help -g -c &&
        test_expect_code 129 git help --config-for-completion add &&
        test_expect_code 129 git help --config-sections-for-completion add
 '
 
+for opt in '-a' '-g' '-c' '--config-for-completion' '--config-sections-for-completion'
+do
+       test_expect_success "invalid usage of '$opt' with [-i|-m|-w]" '
+               git help $opt &&
+               test_expect_code 129 git help $opt -i &&
+               test_expect_code 129 git help $opt -m &&
+               test_expect_code 129 git help $opt -w
+       '
+
+       if test "$opt" = "-a"
+       then
+               continue
+       fi
+
+       test_expect_success "invalid usage of '$opt' with --no-external-commands" '
+               test_expect_code 129 git help $opt --no-external-commands
+       '
+
+       test_expect_success "invalid usage of '$opt' with --no-aliases" '
+               test_expect_code 129 git help $opt --no-external-commands
+       '
+done
+
 test_expect_success "works for commands and guides by default" '
        configure_help &&
        git help status &&
@@ -72,17 +100,17 @@ test_expect_success "--help does not work for guides" "
 
 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_grep "^   clone  " help.output &&
+       test_grep "^   add    " help.output &&
+       test_grep "^   log    " help.output &&
+       test_grep "^   commit " help.output &&
+       test_grep "^   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_grep "^   everyday   " help.output &&
+       test_grep "^   tutorial   " help.output
 '
 
 test_expect_success 'git help fails for non-existing html pages' '
@@ -101,6 +129,12 @@ test_expect_success 'git help succeeds without git.html' '
        test_cmp expect test-browser.log
 '
 
+test_expect_success 'git help --user-interfaces' '
+       git help --user-interfaces >help.output &&
+       grep "^   attributes   " help.output &&
+       grep "^   mailmap   " help.output
+'
+
 test_expect_success 'git help -c' '
        git help -c >help.output &&
        cat >expect <<-\EOF &&
@@ -138,15 +172,92 @@ test_expect_success 'git help --config-sections-for-completion' '
        test_cmp human.munged sections
 '
 
+test_section_spacing () {
+       cat >expect &&
+       "$@" >out &&
+       grep -E "(^[^ ]|^$)" out >actual
+}
+
+test_section_spacing_trailer () {
+       test_section_spacing "$@" &&
+       test_expect_code 1 git >out &&
+       sed -n '/list available subcommands/,$p' <out >>expect
+}
+
+
+for cmd in git "git help"
+do
+       test_expect_success "'$cmd' section spacing" '
+               test_section_spacing_trailer git help <<-\EOF &&
+               usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
+
+               These are common Git commands used in various situations:
+
+               start a working area (see also: git help tutorial)
+
+               work on the current change (see also: git help everyday)
+
+               examine the history and state (see also: git help revisions)
+
+               grow, mark and tweak your common history
+
+               collaborate (see also: git help workflows)
+
+               EOF
+               test_cmp expect actual
+       '
+done
+
+test_expect_success "'git help -a' section spacing" '
+       test_section_spacing \
+               git help -a --no-external-commands --no-aliases <<-\EOF &&
+       See '\''git help <command>'\'' to read about a specific subcommand
+
+       Main Porcelain Commands
+
+       Ancillary Commands / Manipulators
+
+       Ancillary Commands / Interrogators
+
+       Interacting with Others
+
+       Low-level Commands / Manipulators
+
+       Low-level Commands / Interrogators
+
+       Low-level Commands / Syncing Repositories
+
+       Low-level Commands / Internal Helpers
+
+       User-facing repository, command and file interfaces
+
+       Developer-facing file formats, protocols and other interfaces
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success "'git help -g' section spacing" '
+       test_section_spacing_trailer git help -g <<-\EOF &&
+       The Git concept guides are:
+
+       EOF
+       test_cmp expect actual
+'
+
 test_expect_success 'generate builtin list' '
+       mkdir -p sub &&
        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
+               (
+                       GIT_CEILING_DIRECTORIES=$(pwd) &&
+                       export GIT_CEILING_DIRECTORIES &&
+                       test_expect_code 129 git -C sub $builtin -h >output 2>&1
+               ) &&
+               test_grep usage output
        '
 done <builtins