git-prompt: work under set -u
Commit afda36dbf3 ("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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
May 13, 2021 at 06:22 UTC
5c0cbdb107c5e1c1474618535fda438f25d260ca
1 file changed
+3
-3
contrib/completion/git-prompt.sh
+3
-3
@@ -433,8 +433,8 @@ __git_ps1 ()
433
fi
434
435
local sparse=""
436
- if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
437
- [ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
436
+ if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
437
+ [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] &&
438
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
439
sparse="|SPARSE"
440
fi
@@ -543,7 +543,7 @@ __git_ps1 ()
543
u="%${ZSH_VERSION+%}"
544
fi
545
546
- if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
546
+ if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
547
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
548
h="?"
549
fi