git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] completion: add GIT_COMPLETION_SHOW_ALL env var

From
Ryan Zoeller <rtzoeller@rtzoeller.com>
Date
Aug 19, 2020, 23:06 UTC
Message-ID
<20200819230523.773348-3-rtzoeller@rtzoeller.com>
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.g5934a15c94
Previous: Ryan Zoeller
Message 9 of 9 in “Support enabling bash completion of all options”
  1. 0/2 Support enabling bash completion of all optionsRyan Zoeller, Aug 19, 2020
  2. 1/2 parse-options: add --git-completion-helper-allRyan Zoeller, Aug 19, 2020
  3. Junio C HamanoAug 19, 2020
  4. Ryan ZoellerAug 19, 2020
  5. Junio C HamanoAug 19, 2020
  6. 2/2 completion: add GIT_COMPLETION_SHOW_ALL env varRyan Zoeller, Aug 19, 2020
  7. 0/2 Support enabling bash completion of all optionsRyan Zoeller, Aug 19, 2020
  8. 1/2 parse-options: add --git-completion-helper-allRyan Zoeller, Aug 19, 2020
  9. 2/2 completion: add GIT_COMPLETION_SHOW_ALL env varRyan Zoeller, Aug 19, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.