Fix git capsule fallback when __git_ps1 is empty
This commit is contained in:
@@ -432,6 +432,6 @@
|
||||
"On macOS, installer is per-user and sources from .bashrc/.bash_profile.",
|
||||
"Seasonal palettes and contest pack are now documented directly in main.",
|
||||
"README uses images/bash-pallete.png.",
|
||||
"Git capsule prefers __git_ps1 and falls back to git symbolic-ref/short hash when git-prompt is unavailable."
|
||||
"Git capsule prefers __git_ps1 and falls back to git symbolic-ref/short hash when git-prompt is unavailable or returns empty."
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user