completion: add GIT_COMPLETION_SHOW_ALL env var
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>
Ryan Zoeller committed
Aug 19, 2020 at 23:06 UTC
c099f579b9876447cea36ebd1040507fedd3292a
1 file changed
+13
-1
contrib/completion/git-completion.bash
+13
-1
@@ -39,6 +39,11 @@
39
# When set to "1", do not include "DWIM" suggestions in git-checkout
40
# and git-switch completion (e.g., completing "foo" when "origin/foo"
41
# exists).
42
+#
43
+# GIT_COMPLETION_SHOW_ALL
44
+#
45
+# When set to "1" suggest all options, including options which are
46
+# typically hidden (e.g. '--allow-empty' for 'git commit').
47
48
case "$COMP_WORDBREAKS" in
49
*:*) : great ;;
@@ -411,10 +416,17 @@ __gitcomp_builtin ()
416
local options
417
eval "options=\${$var-}"
418
419
+ local completion_helper
420
+ if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then
421
+ completion_helper="--git-completion-helper-all"
422
+ else
423
+ completion_helper="--git-completion-helper"
424
+ fi
425
+
426
if [ -z "$options" ]; then
427
# leading and trailing spaces are significant to make
428
# option removal work correctly.
417
- options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return
429
+ options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return
430
431
for i in $excl; do
432
options="${options/ $i / }"