zsh compat: separate variable declaration from first set

This commit is contained in:
Anthony Gelibert 2013-09-18 10:56:36 +02:00 committed by Olivier Mengué
parent 02d6f3f376
commit 141131502a

View File

@ -741,7 +741,8 @@ _lp_git_branch_color()
branch="$(_lp_git_branch)"
if [[ -n "$branch" ]] ; then
local end="$NO_COL"
local end
end="$NO_COL"
if \git status 2>/dev/null | grep -q '\(# Untracked\)'; then
end="$LP_COLOR_CHANGES$LP_MARK_UNTRACKED$end"
fi
@ -766,10 +767,12 @@ _lp_git_branch_color()
fi
fi
local shortstat="$(LANG=C \git diff --shortstat 2>/dev/null)"
local shortstat
shortstat="$(LANG=C \git diff --shortstat 2>/dev/null)"
if [[ -n "$shortstat" ]] ; then
local has_lines
#has_lines=$(\git diff --numstat 2>/dev/null | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d/-%d\n", plus, minus)}')
local has_lines=${shortstat/*changed, /}
has_lines=${shortstat/*changed, /}
has_lines=${has_lines/ inser*, /\/-}
has_lines=${has_lines/ del*/}
[[ "$shortstat" = *insertion* ]] && has_lines="+${has_lines/ inser*/}" || has_lines="-$has_lines"