This commit is contained in:
Steven 2018-04-15 12:49:44 +00:00 committed by GitHub
commit 13014797b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,12 +73,11 @@ function git_current_branch() {
echo ${ref#refs/heads/}
}
# Gets the number of commits ahead from remote
function git_commits_ahead() {
if command git rev-parse --git-dir &>/dev/null; then
local commits="$(git rev-list --count @{upstream}..HEAD)"
if [[ "$commits" != 0 ]]; then
local commits="$(git rev-list --count @{upstream}..HEAD 2> /dev/null)"
if (( commits )); then
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi
fi
@ -87,8 +86,8 @@ function git_commits_ahead() {
# Gets the number of commits behind remote
function git_commits_behind() {
if command git rev-parse --git-dir &>/dev/null; then
local commits="$(git rev-list --count HEAD..@{upstream})"
if [[ "$commits" != 0 ]]; then
local commits="$(git rev-list --count HEAD..@{upstream} 2> /dev/null)"
if (( commits )); then
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
fi
fi