git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH] completion: audit and guard $GIT_* against unset use
@ 2021-04-08  7:06 Ville Skyttä
  2021-04-08 17:45 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Ville Skyttä @ 2021-04-08  7:06 UTC (permalink / raw)
  To: git

$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(-)

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
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] completion: audit and guard $GIT_* against unset use
  2021-04-08  7:06 [PATCH] completion: audit and guard $GIT_* against unset use Ville Skyttä
@ 2021-04-08 17:45 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2021-04-08 17:45 UTC (permalink / raw)
  To: Ville Skyttä; +Cc: git

Ville Skyttä <ville.skytta@iki.fi> writes:

> $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.

>
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-08 17:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08  7:06 [PATCH] completion: audit and guard $GIT_* against unset use Ville Skyttä
2021-04-08 17:45 ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git