2015-08-26 15:20:13 +00:00
|
|
|
function git_ahead -a ahead behind diverged none
|
2016-01-02 19:20:52 +00:00
|
|
|
not git_is_repo; and return
|
|
|
|
|
2018-06-08 20:58:16 +00:00
|
|
|
set -l commit_count (command git rev-list --count --left-right "@{upstream}...HEAD" 2> /dev/null)
|
2016-01-02 19:20:52 +00:00
|
|
|
|
|
|
|
switch "$commit_count"
|
|
|
|
case ""
|
|
|
|
# no upstream
|
|
|
|
case "0"\t"0"
|
2016-01-21 11:47:11 +00:00
|
|
|
test -n "$none"; and echo "$none"; or echo ""
|
2016-01-02 19:20:52 +00:00
|
|
|
case "*"\t"0"
|
2016-01-21 11:47:11 +00:00
|
|
|
test -n "$behind"; and echo "$behind"; or echo "-"
|
2016-01-02 19:20:52 +00:00
|
|
|
case "0"\t"*"
|
2016-01-21 11:47:11 +00:00
|
|
|
test -n "$ahead"; and echo "$ahead"; or echo "+"
|
2016-01-02 19:20:52 +00:00
|
|
|
case "*"
|
2016-01-21 11:47:11 +00:00
|
|
|
test -n "$diverged"; and echo "$diverged"; or echo "±"
|
2015-08-26 15:20:13 +00:00
|
|
|
end
|
|
|
|
end
|