]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ab/help-config-vars'
authorJunio C Hamano <gitster@pobox.com>
Wed, 13 Oct 2021 22:15:58 +0000 (15:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 Oct 2021 22:15:58 +0000 (15:15 -0700)
Teach "git help -c" into helping the command line completion of
configuration variables.

* ab/help-config-vars:
  help: move column config discovery to help.c library
  help / completion: make "git help" do the hard work
  help tests: test --config-for-completion option & output
  help: simplify by moving to OPT_CMDMODE()
  help: correct logic error in combining --all and --guides
  help: correct logic error in combining --all and --config
  help tests: add test for --config output
  help: correct usage & behavior of "git help --guides"
  help: correct the usage string in -h and documentation

1  2 
builtin/help.c
parse-options.h
t/t0012-help.sh

diff --cc builtin/help.c
Simple merge
diff --cc parse-options.h
Simple merge
diff --cc t/t0012-help.sh
index 913f34c8e9df2d4b4dd5e301d0774907b39b068e,60d713021f91c9b2bd1784cf440d2bee8c9aeb68..91b68c74a154a97c50f1011ebf5ec70c2ce66a33
@@@ -73,22 -85,43 +85,59 @@@ test_expect_success 'git help -g' 
        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 'git help -c' '
+       git help -c >help.output &&
+       cat >expect <<-\EOF &&
+       '\''git help config'\'' for more information
+       EOF
+       grep -v -E \
+               -e "^[^.]+\.[^.]+$" \
+               -e "^[^.]+\.[^.]+\.[^.]+$" \
+               help.output >actual &&
+       test_cmp expect actual
+ '
+ test_expect_success 'git help --config-for-completion' '
+       git help -c >human &&
+       grep -E \
+            -e "^[^.]+\.[^.]+$" \
+            -e "^[^.]+\.[^.]+\.[^.]+$" human |
+            sed -e "s/\*.*//" -e "s/<.*//" |
+            sort -u >human.munged &&
+       git help --config-for-completion >vars &&
+       test_cmp human.munged vars
+ '
+ test_expect_success 'git help --config-sections-for-completion' '
+       git help -c >human &&
+       grep -E \
+            -e "^[^.]+\.[^.]+$" \
+            -e "^[^.]+\.[^.]+\.[^.]+$" human |
+            sed -e "s/\..*//" |
+            sort -u >human.munged &&
+       git help --config-sections-for-completion >sections &&
+       test_cmp human.munged sections
+ '
  test_expect_success 'generate builtin list' '
        git --list-cmds=builtins >builtins
  '