Rework behind / ahead commit count

This commit is contained in:
Lucas 2019-12-10 11:31:47 +00:00
parent 09bf6ae01a
commit 349ce73952
1 changed files with 7 additions and 7 deletions

View File

@ -38,13 +38,13 @@ shgit()
[ -n "$(git status --porcelain)" ] && status=${SHGIT_SEP}*
commits=$(git rev-list --left-right --count @{upstream}...HEAD \
2>/dev/null | {
t=
IFS=" " read -r behind ahead
[ ${behind:-0} -gt 0 ] && t=$t"v$behind"
[ ${ahead:-0} -gt 0 ] && t=$t"^$ahead"
[ -n "$t" ] && printf "%s" "$SHGIT_SEP" "$t"
})
2>/dev/null | tr "\t" ^)
if [ -n "$commits" ]; then
commits=v$commits
commits=${commits#v0}
commits=${commits%^0}
commits=${commits:+$SHGIT_SEP$commits}
fi
printf "%s%s%s" "$SHGIT_BEGIN" "$name$rb$status$commits" "$SHGIT_END"
}