summaryrefslogtreecommitdiff
path: root/contrib/completion/git-completion.bash
diff options
context:
space:
mode:
authorRyan Zoeller <rtzoeller@rtzoeller.com>2020-08-19 23:06:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-08-20 00:46:17 (GMT)
commitc099f579b9876447cea36ebd1040507fedd3292a (patch)
tree6d30d32d10e5312a248fd26de900f764571f344e /contrib/completion/git-completion.bash
parenta0abe5e3b72c721a687ad9dc1a4a9bafe938c738 (diff)
downloadgit-c099f579b9876447cea36ebd1040507fedd3292a.zip
git-c099f579b9876447cea36ebd1040507fedd3292a.tar.gz
git-c099f579b9876447cea36ebd1040507fedd3292a.tar.bz2
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>
Diffstat (limited to 'contrib/completion/git-completion.bash')
-rw-r--r--contrib/completion/git-completion.bash14
1 files changed, 13 insertions, 1 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 700d44a..9147fba 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -39,6 +39,11 @@
# 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 / }"