Rework behind / ahead commit count

This commit is contained in:
Lucas 2019-12-10 11:31:47 +00:00
parent 09bf6ae01a
commit 349ce73952

View File

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