Skip to content

Commit c099f57

Browse files
rtzoellergitster
authored andcommitted
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>
1 parent a0abe5e commit c099f57

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
# When set to "1", do not include "DWIM" suggestions in git-checkout
4040
# and git-switch completion (e.g., completing "foo" when "origin/foo"
4141
# 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').
4247

4348
case "$COMP_WORDBREAKS" in
4449
*:*) : great ;;
@@ -411,10 +416,17 @@ __gitcomp_builtin ()
411416
local options
412417
eval "options=\${$var-}"
413418

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+
414426
if [ -z "$options" ]; then
415427
# leading and trailing spaces are significant to make
416428
# option removal work correctly.
417-
options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return
429+
options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return
418430

419431
for i in $excl; do
420432
options="${options/ $i / }"

0 commit comments

Comments
 (0)