From fdc05b0dcb54f5adc6f6b55d678f2b8219ac77f9 Mon Sep 17 00:00:00 2001 From: Steven Spasbo Date: Mon, 28 Aug 2017 11:54:09 -0700 Subject: [PATCH] Fixed git ahead/behind lib functionality --- lib/git.zsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index f7eccb81d..251392f0f 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -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