Commit ec8c209f authored by Itzik Ephraim's avatar Itzik Ephraim

A different approach in git_ahead

parent ccb18ed9
function git_ahead -a ahead behind diverged none function git_ahead -a ahead behind diverged none
git_is_repo; and begin not git_is_repo; and return
test -z "$ahead"; and set ahead "+"
test -z "$behind"; and set behind "-" set -l commit_count (command git rev-list --count --left-right "@{upstream}...HEAD" ^/dev/null)
test -z "$diverged"; and set diverged "±"
test -z "$none"; and set none "" switch "$commit_count"
command git rev-list --left-right "@{upstream}...HEAD" ^/dev/null \ case ""
| awk "/>/ {a += 1} /</ {b += 1} \ # no upstream
{if (a > 0) nextfile} END \ case "0"\t"0"
{if (a > 0 && b > 0) print \"$diverged\"; \ test -z "$ahead"; and echo "$ahead"
else if (a > 0) print \"$ahead\"; \ or echo ""
else if (b > 0) print \"$behind\"; case "*"\t"0"
else printf \"$none\"}" test -z "$behind"; and echo "$behind"
or echo "-"
case "0"\t"*"
test -z "$ahead"; and echo "$ahead"
or echo "+"
case "*"
test -z "$diverged"; and echo "$diverged"
or echo "±"
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment