git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ville Skyttä" <ville.skytta@iki.fi>
Cc: git@vger.kernel.org, "SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH] completion: avoid config variable name lookup error in nounset mode
Date: Wed, 11 Aug 2021 12:35:19 -0700	[thread overview]
Message-ID: <xmqqfsvf93m0.fsf@gitster.g> (raw)
In-Reply-To: <20210811191637.775693-1-ville.skytta@iki.fi> ("Ville Skyttä"'s message of "Wed, 11 Aug 2021 22:16:37 +0300")

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

  reply	other threads:[~2021-08-11 19:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-08-11 19:40 ` Felipe Contreras

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=xmqqfsvf93m0.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=szeder.dev@gmail.com \
    --cc=ville.skytta@iki.fi \
    /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;
as well as URLs for NNTP newsgroup(s).