You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
555 B
Fish
16 lines
555 B
Fish
9 years ago
|
function git_ahead -a ahead behind diverged none
|
||
|
git_is_repo; and begin
|
||
|
test -z "$ahead"; and set ahead "+"
|
||
|
test -z "behind"; and set behind "-"
|
||
|
test -z "diverged"; and set diverged "±"
|
||
|
test -z "none"; and set none ""
|
||
|
command git rev-list --left-right "@{upstream}...HEAD" ^/dev/null \
|
||
|
| awk "/>/ {a += 1} /</ {b += 1} \
|
||
|
{if (a > 0) nextfile} END \
|
||
|
{if (a > 0 && b > 0) print \"$diverged\"; \
|
||
|
else if (a > 0) print \"$ahead\"; \
|
||
|
else if (b > 0) print \"$behind\";
|
||
|
else printf \"$none\"}"
|
||
|
end
|
||
|
end
|