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

[PATCH v3 try4 4/4] completion: bash: add correct suffix in variables

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Aug 16, 2021, 09:10 UTC
Message-ID
<20210816091025.548095-5-felipe.contreras@gmail.com>
In-Reply-To
<20210816091025.548095-1-felipe.contreras@gmail.com>

__gitcomp automatically adds a suffix, but __gitcomp_nl and others don't, we need to specify a space by default.

Can be tested with:
  git config branch.autoSetupMe<tab>

This fix only works for versions of bash greater than 4.0, before that "local sfx" creates an empty string, therefore the unset expansion doesn't work. The same happens in zsh.

Therefore we don't add the test for that for now.

The correct fix for all shells requires semantic changes in __gitcomp, but that can be done later.

Cc: SZEDER Gábor <szeder.dev@gmail.com>
Tested-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index b7988f0485..8108eda1e8 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2653,7 +2653,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
-		__gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "$sfx"
+		__gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }"
 		return
 		;;
 	guitool.*.*)
@@ -2687,7 +2687,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__git_compute_all_commands
-		__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "$sfx"
+		__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx- }"
 		return
 		;;
 	remote.*.*)
@@ -2703,7 +2703,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
-		__gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "$sfx"
+		__gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx- }"
 		return
 		;;
 	url.*.*)
-- 
2.32.0.48.g096519100f
Previous: Felipe Contreras
Message 5 of 5 in “completion: bash: a bunch of fixes”
  1. 0/4 completion: bash: a bunch of fixesFelipe Contreras, Aug 16, 2021
  2. 1/4 completion: bash: fix prefix detection in branch.*Felipe Contreras, Aug 16, 2021
  3. 3/4 completion: bash: fix for multiple dash commandsFelipe Contreras, Aug 16, 2021
  4. 2/4 completion: bash: fix for suboptions with valueFelipe Contreras, Aug 16, 2021
  5. 4/4 completion: bash: add correct suffix in variablesFelipe Contreras, Aug 16, 2021

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.