Issue #108 - Zsh:error in git dir if there is new files

It was a problem with local declaration and assignation in the same
time. Don't ask me why zsh complains, but it did.
Also, I took the liberty to make a similar change en bzr part, just a
precaution.
This commit is contained in:
Luc Didry 2013-03-12 20:00:36 +01:00
parent 3d711323d5
commit 22cf1aaafb

View File

@ -657,9 +657,11 @@ _lp_are_vcs_disabled()
_lp_git_branch()
{
[[ "$LP_ENABLE_GIT" != 1 ]] && return
local gitdir="$(git rev-parse --git-dir 2>/dev/null)"
local gitdir
gitdir="$(git rev-parse --git-dir 2>/dev/null)"
[[ $? -ne 0 || "${gitdir##*/}" != .git ]] && return
local branch="$(git symbolic-ref HEAD 2>/dev/null)"
local branch
branch="$(git symbolic-ref HEAD 2>/dev/null)"
[[ $? -ne 0 || -z "$branch" ]] && return
echo "${branch#refs/heads/}"
}
@ -686,14 +688,16 @@ _lp_git_branch_color()
git diff --cached --quiet >/dev/null 2>&1
GDC=$?
local has_untracked=$(git status 2>/dev/null | grep '\(# Untracked\)')
local has_untracked
has_untracked=$(git status 2>/dev/null | grep '\(# Untracked\)')
if [[ -z "$has_untracked" ]] ; then
has_untracked=""
else
has_untracked="$LP_COLOR_CHANGES$LP_MARK_UNTRACKED"
fi
local has_stash=$(git stash list 2>/dev/null)
local has_stash
has_stash=$(git stash list 2>/dev/null)
if [[ -z "$has_stash" ]] ; then
has_stash=""
else
@ -893,7 +897,8 @@ _lp_fossil_branch_color()
_lp_bzr_branch()
{
[[ "$LP_ENABLE_BZR" != 1 ]] && return
local output=$(bzr nick 2> /dev/null)
local output
output=$(bzr nick 2> /dev/null)
[[ $? -ne 0 ]] && return
echo "$output"
}
@ -908,7 +913,8 @@ _lp_bzr_branch()
_lp_bzr_branch_color()
{
[[ "$LP_ENABLE_BZR" != 1 ]] && return
local output=$(bzr version-info --check-clean --custom --template='{branch_nick} {revno} {clean}' 2> /dev/null)
local output
output=$(bzr version-info --check-clean --custom --template='{branch_nick} {revno} {clean}' 2> /dev/null)
local tuple=($output)
local branch=${tuple[0]}
local revno=${tuple[1]}