From: Ryan Zoeller <rtzoeller@rtzoeller.com>
To: git@vger.kernel.org
Cc: Ryan Zoeller <rtzoeller@rtzoeller.com>
Subject: [RFC PATCH 2/2] completion: add GIT_COMPLETION_SHOW_ALL env var
Date: Wed, 19 Aug 2020 17:51:12 +0000 [thread overview]
Message-ID: <20200819175047.692962-3-rtzoeller@rtzoeller.com> (raw)
In-Reply-To: <20200819175047.692962-1-rtzoeller@rtzoeller.com>
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>
---
contrib/completion/git-completion.bash | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 700d44af5b..9147fba3d5 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 / }"
--
2.28.0.260.g5fadab5a9c
next prev parent reply other threads:[~2020-08-19 17:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 17:50 [RFC PATCH 0/2] Support enabling bash completion of all options Ryan Zoeller
2020-08-19 17:51 ` [RFC PATCH 1/2] parse-options: add --git-completion-helper-all Ryan Zoeller
2020-08-19 19:39 ` Junio C Hamano
2020-08-19 20:51 ` Ryan Zoeller
2020-08-19 21:05 ` Junio C Hamano
2020-08-19 17:51 ` Ryan Zoeller [this message]
2020-08-19 23:06 ` [PATCH v2 0/2] Support enabling bash completion of all options Ryan Zoeller
2020-08-19 23:06 ` [PATCH v2 1/2] parse-options: add --git-completion-helper-all Ryan Zoeller
2020-08-19 23:06 ` [PATCH v2 2/2] completion: add GIT_COMPLETION_SHOW_ALL env var Ryan Zoeller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200819175047.692962-3-rtzoeller@rtzoeller.com \
--to=rtzoeller@rtzoeller.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox