Fix git capsule fallback when __git_ps1 is empty

This commit is contained in:
2026-01-24 14:03:33 +00:00
parent 4bd8307bf0
commit 5ed49cc54c
2 changed files with 6 additions and 2 deletions

View File

@@ -169,7 +169,11 @@ __git_capsule() {
if declare -F __git_ps1 >/dev/null 2>&1; then
has_ps1=1
info="$(__git_ps1 "%s" 2>/dev/null)"
else
if [[ -z "$info" ]]; then
has_ps1=0
fi
fi
if [[ -z "$info" ]]; then
if command -v git >/dev/null 2>&1; then
info="$(git symbolic-ref --quiet --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)"
fi