Skip to content

Commit 8162401

Browse files
committed
Merge branch 'vs/prompt-avoid-unset-variable' into maint
The git-prompt scriptlet (in contrib/) was not friendly with those who uses "set -u", which has been fixed. * vs/prompt-avoid-unset-variable: git-prompt.sh: Don't error on null ${ZSH,BASH}_VERSION, $short_sha
2 parents 7949837 + 34d8f5a commit 8162401

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
@@ -355,8 +355,8 @@ __git_ps1 ()
355355
# incorrect.)
356356
#
357357
local ps1_expanded=yes
358-
[ -z "$ZSH_VERSION" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
359-
[ -z "$BASH_VERSION" ] || shopt -q promptvars || ps1_expanded=no
358+
[ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
359+
[ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
360360

361361
local repo_info rev_parse_exit_code
362362
repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
@@ -368,7 +368,7 @@ __git_ps1 ()
368368
return $exit
369369
fi
370370

371-
local short_sha
371+
local short_sha=""
372372
if [ "$rev_parse_exit_code" = "0" ]; then
373373
short_sha="${repo_info##*$'\n'}"
374374
repo_info="${repo_info%$'\n'*}"

0 commit comments

Comments
 (0)