_lp_git_branch: optimize code paths
This commit is contained in:
parent
0c1e66d12a
commit
e4626c4e0f
@ -694,11 +694,11 @@ _lp_git_branch()
|
|||||||
local branch="$(git symbolic-ref HEAD 2>/dev/null)"
|
local branch="$(git symbolic-ref HEAD 2>/dev/null)"
|
||||||
if [[ $? -ne 0 || -z "$branch" ]] ; then
|
if [[ $? -ne 0 || -z "$branch" ]] ; then
|
||||||
# In detached head state, use commit instead
|
# In detached head state, use commit instead
|
||||||
branch="$(git rev-parse --short HEAD 2>/dev/null)"
|
# No escape needed
|
||||||
|
git rev-parse --short HEAD 2>/dev/null
|
||||||
|
else
|
||||||
|
_lp_escape "${branch#refs/heads/}"
|
||||||
fi
|
fi
|
||||||
[[ $? -ne 0 || -z "$branch" ]] && return
|
|
||||||
branch="${branch#refs/heads/}"
|
|
||||||
echo $(_lp_escape "$branch")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set a color depending on the branch state:
|
# Set a color depending on the branch state:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user