Adding git untracked files information (branch* instead of branch if so)

This commit is contained in:
Alex 2012-08-16 14:08:07 +02:00
parent 78b9aff683
commit 3046024b29

View File

@ -569,6 +569,14 @@ _lp_git_branch_color()
git diff --cached --quiet >/dev/null 2>&1 git diff --cached --quiet >/dev/null 2>&1
GDC=$? GDC=$?
local has_untracked
has_untracked=$(git status 2>/dev/null | grep '\(# Untracked\)')
if [[ -z "$has_untracked" ]] ; then
has_untracked=""
else
has_untracked="*"
fi
local has_commit local has_commit
has_commit=$(git rev-list --no-merges --count origin/${branch}..${branch} 2>/dev/null) has_commit=$(git rev-list --no-merges --count origin/${branch}..${branch} 2>/dev/null)
if [[ -z "$has_commit" ]] ; then if [[ -z "$has_commit" ]] ; then
@ -579,16 +587,16 @@ _lp_git_branch_color()
has_lines=$(git diff --numstat | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d/-%d\n", plus, minus)}') has_lines=$(git diff --numstat | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d/-%d\n", plus, minus)}')
if [[ "$has_commit" -gt "0" ]] ; then if [[ "$has_commit" -gt "0" ]] ; then
# Changes to commit and commits to push # Changes to commit and commits to push
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$has_commit${NO_COL})" ret="${LP_COLOR_CHANGES}${branch}${has_untracked}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$has_commit${NO_COL})"
else else
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})" # changes to commit ret="${LP_COLOR_CHANGES}${branch}${has_untracked}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})" # changes to commit
fi fi
else else
if [[ "$has_commit" -gt "0" ]] ; then if [[ "$has_commit" -gt "0" ]] ; then
# some commit(s) to push # some commit(s) to push
ret="${LP_COLOR_COMMITS}${branch}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})" ret="${LP_COLOR_COMMITS}${branch}${has_untracked}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})"
else else
ret="${LP_COLOR_UP}${branch}${NO_COL}" # nothing to commit or push ret="${LP_COLOR_UP}${branch}${has_untracked}${NO_COL}" # nothing to commit or push
fi fi
fi fi
echo -ne "$ret" echo -ne "$ret"