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

Re: [PATCH] completion: audit and guard $GIT_* against unset use

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 8, 2021, 17:45 UTC
Message-ID
<xmqqv98wu0to.fsf@gitster.g>
In-Reply-To
<20210408070641.360431-1-ville.skytta@iki.fi>
Ville Skyttä <ville.skytta@iki.fi> writes:
Show 13 quoted lines
> $GIT_COMPLETION_SHOW_ALL and $GIT_TESTING_ALL_COMMAND_LIST were used
> without guarding against them being unset, causing errors in nounset
> (set -u) mode.
>
> No other nounset-unsafe $GIT_* usages were found.
>
> While at it, remove a superfluous (duplicate) unset guard from $GIT_DIR
> in __git_find_repo_path.
>
> Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
> ---
>  contrib/completion/git-completion.bash | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
Looks good to me.  Will queue.  Thanks.
Show 32 quoted lines
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index e1a66954fe..29b859a0b8 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -77,7 +77,7 @@ __git_find_repo_path ()
>  		test -d "$__git_dir" &&
>  		__git_repo_path="$__git_dir"
>  	elif [ -n "${GIT_DIR-}" ]; then
> -		test -d "${GIT_DIR-}" &&
> +		test -d "$GIT_DIR" &&
>  		__git_repo_path="$GIT_DIR"
>  	elif [ -d .git ]; then
>  		__git_repo_path=.git
> @@ -427,7 +427,7 @@ __gitcomp_builtin ()
>  
>  	if [ -z "$options" ]; then
>  		local completion_helper
> -		if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then
> +		if [ "${GIT_COMPLETION_SHOW_ALL-}" = "1" ]; then
>  			completion_helper="--git-completion-helper-all"
>  		else
>  			completion_helper="--git-completion-helper"
> @@ -1910,7 +1910,7 @@ _git_help ()
>  		return
>  		;;
>  	esac
> -	if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
> +	if test -n "${GIT_TESTING_ALL_COMMAND_LIST-}"
>  	then
>  		__gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
>  	else
Previous: Ville Skyttä
Message 2 of 2 in “completion: audit and guard $GIT_* against unset use”
  1. completion: audit and guard $GIT_* against unset useVille Skyttä, Apr 8, 2021
  2. Junio C HamanoApr 8, 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.