]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: protect prompt against unset SHOWUPSTREAM in nounset mode
authorVille Skyttä <ville.skytta@iki.fi>
Mon, 1 Apr 2024 19:07:51 +0000 (19:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2024 19:38:23 +0000 (12:38 -0700)
As it stands, the only call site of `__git_ps1_show_upstream` checks
that the `GIT_PS1_SHOWUPSTREAM` variable is set, so this is effectively
a no-op. However, that might change, and chances of noticing the
unprotected use might not be that high when it does.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-prompt.sh

index 3826f52decfe767c95d2ccc799179b2d609d0af9..5330e769a72a86df6c4d2e47d796bc4e0cb90773 100644 (file)
@@ -141,7 +141,7 @@ __git_ps1_show_upstream ()
 
        # parse configuration values
        local option
-       for option in ${GIT_PS1_SHOWUPSTREAM}; do
+       for option in ${GIT_PS1_SHOWUPSTREAM-}; do
                case "$option" in
                git|svn) upstream_type="$option" ;;
                verbose) verbose=1 ;;