2015-08-26 23:20:13 +08:00
|
|
|
function git_ahead -a ahead behind diverged none
|
2016-01-03 03:20:52 +08:00
|
|
|
not git_is_repo; and return
|
|
|
|
|
|
|
|
set -l commit_count (command git rev-list --count --left-right "@{upstream}...HEAD" ^/dev/null)
|
|
|
|
|
|
|
|
switch "$commit_count"
|
|
|
|
case ""
|
|
|
|
# no upstream
|
|
|
|
case "0"\t"0"
|
2016-01-20 01:00:21 +08:00
|
|
|
test -z "$none"; and echo "$none"
|
2016-01-03 03:20:52 +08:00
|
|
|
or echo ""
|
|
|
|
case "*"\t"0"
|
|
|
|
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 "±"
|
2015-08-26 23:20:13 +08:00
|
|
|
end
|
|
|
|
end
|