]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode
authorVille Skyttä <ville.skytta@iki.fi>
Mon, 1 Apr 2024 11:30:33 +0000 (11:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2024 15:31:54 +0000 (08:31 -0700)
`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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-prompt.sh

index 71f179cba3fbda3bc93de461649cf75bb08c6653..3826f52decfe767c95d2ccc799179b2d609d0af9 100644 (file)
@@ -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