{"thread":{"id":"55453","subject":"[PATCH] completion: audit and guard $GIT_* against unset use","startedAt":"2021-04-08T07:06:55Z","lastAt":"2021-04-08T17:46:00Z","messageCount":2,"participants":["Ville Skyttä","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"421196","messageId":"20210408070641.360431-1-ville.skytta@iki.fi","threadId":"55453","inReplyTo":null,"subject":"[PATCH] completion: audit and guard $GIT_* against unset use","fromName":"Ville Skyttä","fromEmail":"ville.skytta@iki.fi","sentAt":"2021-04-08T07:06:41Z","receivedAt":"2021-04-08T07:06:55Z","isPatch":true,"sender":{"key":"ville.skytta@iki.fi","avatar":"https://avatars.githubusercontent.com/u/109152?v=4"},"body":"$GIT_COMPLETION_SHOW_ALL and $GIT_TESTING_ALL_COMMAND_LIST were used\nwithout guarding against them being unset, causing errors in nounset\n(set -u) mode.\n\nNo other nounset-unsafe $GIT_* usages were found.\n\nWhile at it, remove a superfluous (duplicate) unset guard from $GIT_DIR\nin __git_find_repo_path.\n\nSigned-off-by: Ville Skyttä <ville.skytta@iki.fi>\n---\n contrib/completion/git-completion.bash | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e1a66954fe..29b859a0b8 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -77,7 +77,7 @@ __git_find_repo_path ()\n \t\ttest -d \"$__git_dir\" &&\n \t\t__git_repo_path=\"$__git_dir\"\n \telif [ -n \"${GIT_DIR-}\" ]; then\n-\t\ttest -d \"${GIT_DIR-}\" &&\n+\t\ttest -d \"$GIT_DIR\" &&\n \t\t__git_repo_path=\"$GIT_DIR\"\n \telif [ -d .git ]; then\n \t\t__git_repo_path=.git\n@@ -427,7 +427,7 @@ __gitcomp_builtin ()\n \n \tif [ -z \"$options\" ]; then\n \t\tlocal completion_helper\n-\t\tif [ \"$GIT_COMPLETION_SHOW_ALL\" = \"1\" ]; then\n+\t\tif [ \"${GIT_COMPLETION_SHOW_ALL-}\" = \"1\" ]; then\n \t\t\tcompletion_helper=\"--git-completion-helper-all\"\n \t\telse\n \t\t\tcompletion_helper=\"--git-completion-helper\"\n@@ -1910,7 +1910,7 @@ _git_help ()\n \t\treturn\n \t\t;;\n \tesac\n-\tif test -n \"$GIT_TESTING_ALL_COMMAND_LIST\"\n+\tif test -n \"${GIT_TESTING_ALL_COMMAND_LIST-}\"\n \tthen\n \t\t__gitcomp \"$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk\"\n \telse\n-- \n2.25.1\n\n"},{"id":"421249","messageId":"xmqqv98wu0to.fsf@gitster.g","threadId":"55453","inReplyTo":"20210408070641.360431-1-ville.skytta@iki.fi","subject":"Re: [PATCH] completion: audit and guard $GIT_* against unset use","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-08T17:45:55Z","receivedAt":"2021-04-08T17:46:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ville Skyttä <ville.skytta@iki.fi> writes:\n\n> $GIT_COMPLETION_SHOW_ALL and $GIT_TESTING_ALL_COMMAND_LIST were used\n> without guarding against them being unset, causing errors in nounset\n> (set -u) mode.\n>\n> No other nounset-unsafe $GIT_* usages were found.\n>\n> While at it, remove a superfluous (duplicate) unset guard from $GIT_DIR\n> in __git_find_repo_path.\n>\n> Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>\n> ---\n>  contrib/completion/git-completion.bash | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n\nLooks good to me.  Will queue.  Thanks.\n\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index e1a66954fe..29b859a0b8 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -77,7 +77,7 @@ __git_find_repo_path ()\n>  \t\ttest -d \"$__git_dir\" &&\n>  \t\t__git_repo_path=\"$__git_dir\"\n>  \telif [ -n \"${GIT_DIR-}\" ]; then\n> -\t\ttest -d \"${GIT_DIR-}\" &&\n> +\t\ttest -d \"$GIT_DIR\" &&\n>  \t\t__git_repo_path=\"$GIT_DIR\"\n>  \telif [ -d .git ]; then\n>  \t\t__git_repo_path=.git\n> @@ -427,7 +427,7 @@ __gitcomp_builtin ()\n>  \n>  \tif [ -z \"$options\" ]; then\n>  \t\tlocal completion_helper\n> -\t\tif [ \"$GIT_COMPLETION_SHOW_ALL\" = \"1\" ]; then\n> +\t\tif [ \"${GIT_COMPLETION_SHOW_ALL-}\" = \"1\" ]; then\n>  \t\t\tcompletion_helper=\"--git-completion-helper-all\"\n>  \t\telse\n>  \t\t\tcompletion_helper=\"--git-completion-helper\"\n> @@ -1910,7 +1910,7 @@ _git_help ()\n>  \t\treturn\n>  \t\t;;\n>  \tesac\n> -\tif test -n \"$GIT_TESTING_ALL_COMMAND_LIST\"\n> +\tif test -n \"${GIT_TESTING_ALL_COMMAND_LIST-}\"\n>  \tthen\n>  \t\t__gitcomp \"$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk\"\n>  \telse\n"}]}