git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode
@ 2024-04-01 11:30 Ville Skyttä
  2024-04-01 15:31 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Ville Skyttä @ 2024-04-01 11:30 UTC (permalink / raw)
  To: git

`GIT_PS1_SHOWCONFLICTSTATE` is a user variable that might not be set,
causing errors when the shell is in `nounset` mode.

Take into account on access by falling back to an empty string.

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 71f179cba3..3826f52dec 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -528,7 +528,7 @@ __git_ps1 ()
 	fi
 
 	local conflict="" # state indicator for unresolved conflicts
-	if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] &&
+	if [[ "${GIT_PS1_SHOWCONFLICTSTATE-}" == "yes" ]] &&
 	   [[ $(git ls-files --unmerged 2>/dev/null) ]]; then
 		conflict="|CONFLICT"
 	fi
-- 
2.40.1


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

end of thread, other threads:[~2024-04-01 19:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-01 11:30 [PATCH] completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode Ville Skyttä
2024-04-01 15:31 ` Junio C Hamano
2024-04-01 17:07   ` Ville Skyttä
2024-04-01 17:26     ` Junio C Hamano
2024-04-01 19:10       ` Ville Skyttä
2024-04-01 19:38         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).