# [PATCH] completion: protect prompt against unset SHOWUPSTREAM in nounset mode

1 messages from 2024-04-01 to 2024-04-01. Participants: Ville Skyttä.
Thread: https://gitlist.dev/t/61244

## Ville Skyttä, 2024-04-01 19:07

Subject: [PATCH] completion: protect prompt against unset SHOWUPSTREAM in nounset mode
Message-ID: <20240401190751.8676-1-ville.skytta@iki.fi>
URL: https://gitlist.dev/e/20240401190751.8676-1-ville.skytta%40iki.fi

```
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>
---
 contrib/completion/git-prompt.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 3826f52dec..5330e769a7 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -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 ;;
-- 
2.40.1


```
