Skip to content

Commit 5c0cbdb

Browse files
newrengitster
authored andcommitted
git-prompt: work under set -u
Commit afda36d ("git-prompt: include sparsity state as well", 2020-06-21) added the use of some variables to control how to show sparsity state in the git prompt, but implicitly assumed that undefined variables would be treated as the empty string. This breaks users who run under 'set -u'; fix the code to be more explicit. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 48bf2fa commit 5c0cbdb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contrib/completion/git-prompt.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ __git_ps1 ()
433433
fi
434434

435435
local sparse=""
436-
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
437-
[ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
436+
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
437+
[ -z "${GIT_PS1_OMITSPARSESTATE-}" ] &&
438438
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
439439
sparse="|SPARSE"
440440
fi
@@ -543,7 +543,7 @@ __git_ps1 ()
543543
u="%${ZSH_VERSION+%}"
544544
fi
545545

546-
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
546+
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
547547
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
548548
h="?"
549549
fi

0 commit comments

Comments
 (0)