[PATCH] completion: avoid config variable name lookup error in nounset mode

Subsystems: the rest

STALE1830d

2 messages, 2 authors, 2021-08-11 · open the first message on its own page

[PATCH] completion: avoid config variable name lookup error in nounset mode

From: Ville Skyttä <hidden>
Date: 2021-08-11 19:16:42

Config variable name lookup accesses the `sfx` variable before it has
been set, causing an error in "nounset" mode. Initialize to an empty
string to avoid that.

    $ git config submodule.<Tab>bash: sfx: unbound variable

Signed-off-by: Ville Skyttä <redacted>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 4bdd27ddc8..ecc9352755 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2631,7 +2631,7 @@ __git_complete_config_variable_value ()
 #                 subsections) instead of the default space.
 __git_complete_config_variable_name ()
 {
-	local cur_="$cur" sfx
+	local cur_="$cur" sfx=""
 
 	while test $# != 0; do
 		case "$1" in
-- 
2.25.1

RE: [PATCH] completion: avoid config variable name lookup error in nounset mode

From: Felipe Contreras <hidden>
Date: 2021-08-11 19:40:45

Ville Skyttä wrote:
quoted hunk
Config variable name lookup accesses the `sfx` variable before it has
been set, causing an error in "nounset" mode. Initialize to an empty
string to avoid that.

    $ git config submodule.<Tab>bash: sfx: unbound variable

Signed-off-by: Ville Skyttä <redacted>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 4bdd27ddc8..ecc9352755 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2631,7 +2631,7 @@ __git_complete_config_variable_value ()
 #                 subsections) instead of the default space.
 __git_complete_config_variable_name ()
 {
-	local cur_="$cur" sfx
+	local cur_="$cur" sfx=""
For what it's worth this would break a fix I've sent several times
already [1].

The proper fix requires changing __gitcomp as well, after that sfx can
simply be " ".

All the patches that fix all these issues have been sent, and if you
want to try them out check git-completion [2].

Cheers.

[1] https://lore.kernel.org/git/20210707023146.3132162-5-felipe.contreras@gmail.com/
[2] https://github.com/felipec/git-completion

-- 
Felipe Contreras
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help