]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: add GIT_COMPLETION_SHOW_ALL env var
authorRyan Zoeller <rtzoeller@rtzoeller.com>
Wed, 19 Aug 2020 23:06:13 +0000 (23:06 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Aug 2020 00:46:17 +0000 (17:46 -0700)
When set to 1, GIT_COMPLETION_SHOW_ALL causes --git-completion-helper-all
to be passed instead of --git-completion-helper.

Signed-off-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index 700d44af5bedb4bdcc6260bad5904e3fe869358c..9147fba3d5c34e617f94129b02459d4579595da8 100644 (file)
 #     When set to "1", do not include "DWIM" suggestions in git-checkout
 #     and git-switch completion (e.g., completing "foo" when "origin/foo"
 #     exists).
+#
+#   GIT_COMPLETION_SHOW_ALL
+#
+#     When set to "1" suggest all options, including options which are
+#     typically hidden (e.g. '--allow-empty' for 'git commit').
 
 case "$COMP_WORDBREAKS" in
 *:*) : great ;;
@@ -411,10 +416,17 @@ __gitcomp_builtin ()
        local options
        eval "options=\${$var-}"
 
+       local completion_helper
+       if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then
+               completion_helper="--git-completion-helper-all"
+       else
+               completion_helper="--git-completion-helper"
+       fi
+
        if [ -z "$options" ]; then
                # leading and trailing spaces are significant to make
                # option removal work correctly.
-               options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return
+               options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return
 
                for i in $excl; do
                        options="${options/ $i / }"