* [PATCH] completion: avoid config variable name lookup error in nounset mode
@ 2021-08-11 19:16 Ville Skyttä
2021-08-11 19:35 ` Junio C Hamano
2021-08-11 19:40 ` Felipe Contreras
0 siblings, 2 replies; 3+ messages in thread
From: Ville Skyttä @ 2021-08-11 19:16 UTC (permalink / raw)
To: git
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ä <ville.skytta@iki.fi>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] completion: avoid config variable name lookup error in nounset mode
2021-08-11 19:16 [PATCH] completion: avoid config variable name lookup error in nounset mode Ville Skyttä
@ 2021-08-11 19:35 ` Junio C Hamano
2021-08-11 19:40 ` Felipe Contreras
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2021-08-11 19:35 UTC (permalink / raw)
To: Ville Skyttä; +Cc: git, SZEDER Gábor
Ville Skyttä <ville.skytta@iki.fi> writes:
> Config variable name lookup accesses the `sfx` variable before it has
The above sounds as if the function always makes an access to an
uninitialized variable, which puzzled me. The problem exists only
when called from some callers that do not use the --sfx=X option,
which may be worth mentioning.
I see that, ever since the helper function was introduced at e1e00089
(completion: complete configuration sections and variable names for
'git -c', 2019-08-13), it would have upset 'set -u' when the caller
does not pass --sfx=X option, and even in that original version,
there was such a caller (the original author Cc'ed).
And the fix looks trivially correct.
I'll be busy preparing the -rc2 today, and will not be queuing this
patch right now, though. As this is not a recent regression, waiting
for the current release cycle to be over and sending a reroll later
next week would be greatly appreciated.
Thanks.
> 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ä <ville.skytta@iki.fi>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] completion: avoid config variable name lookup error in nounset mode
2021-08-11 19:16 [PATCH] completion: avoid config variable name lookup error in nounset mode Ville Skyttä
2021-08-11 19:35 ` Junio C Hamano
@ 2021-08-11 19:40 ` Felipe Contreras
1 sibling, 0 replies; 3+ messages in thread
From: Felipe Contreras @ 2021-08-11 19:40 UTC (permalink / raw)
To: Ville Skyttä, git
Ville Skyttä wrote:
> 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ä <ville.skytta@iki.fi>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-11 19:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 19:16 [PATCH] completion: avoid config variable name lookup error in nounset mode Ville Skyttä
2021-08-11 19:35 ` Junio C Hamano
2021-08-11 19:40 ` Felipe Contreras
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).