mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-23 02:59:27 +08:00
19 lines
519 B
Fish
19 lines
519 B
Fish
function git_ahead -a ahead behind diverged none
|
|
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"
|
|
test -n "$none"; and echo "$none"; or echo ""
|
|
case "*"\t"0"
|
|
test -n "$behind"; and echo "$behind"; or echo "-"
|
|
case "0"\t"*"
|
|
test -n "$ahead"; and echo "$ahead"; or echo "+"
|
|
case "*"
|
|
test -n "$diverged"; and echo "$diverged"; or echo "±"
|
|
end
|
|
end
|