completion: audit and guard $GIT_* against unset use
$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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ville Skyttä committed
Apr 8, 2021 at 10:06 UTC
c5c0548d793edf4a6e319f237f3a01a1f093bbd7
1 file changed
+3
-3
contrib/completion/git-completion.bash
+3
-3
@@ -77,7 +77,7 @@ __git_find_repo_path ()
77
test -d "$__git_dir" &&
78
__git_repo_path="$__git_dir"
79
elif [ -n "${GIT_DIR-}" ]; then
80
- test -d "${GIT_DIR-}" &&
80
+ test -d "$GIT_DIR" &&
81
__git_repo_path="$GIT_DIR"
82
elif [ -d .git ]; then
83
__git_repo_path=.git
@@ -427,7 +427,7 @@ __gitcomp_builtin ()
427
428
if [ -z "$options" ]; then
429
local completion_helper
430
- if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then
430
+ if [ "${GIT_COMPLETION_SHOW_ALL-}" = "1" ]; then
431
completion_helper="--git-completion-helper-all"
432
else
433
completion_helper="--git-completion-helper"
@@ -1910,7 +1910,7 @@ _git_help ()
1910
return
1911
;;
1912
esac
1913
- if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
1913
+ if test -n "${GIT_TESTING_ALL_COMMAND_LIST-}"
1914
then
1915
__gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
1916
else