summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven <stevenspasbo@gmail.com>2016-08-01 08:48:46 -0700
committerMarc Cornellà <marc.cornella@live.com>2016-08-01 17:48:46 +0200
commit61981951b1380c431e464a63d394ce890e751b97 (patch)
treec92c08f4a07de6d66e7fa58744ff644c05daf314
parenta7e30b26baa94bac99d9d05cf642bd1942ae1787 (diff)
downloadzsh-61981951b1380c431e464a63d394ce890e751b97.tar.gz
zsh-61981951b1380c431e464a63d394ce890e751b97.tar.bz2
zsh-61981951b1380c431e464a63d394ce890e751b97.zip
Updated git_commits_ahead function (#5247)
* Function wasn't returning correct value * Updated underlying git command * Kept echo command from previous function for backwards compatibility * Kept function consistent with git_commits_behind
-rw-r--r--lib/git.zsh5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/git.zsh b/lib/git.zsh
index c79cc0d8e..648a766b5 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -76,9 +76,8 @@ function git_current_branch() {
# Gets the number of commits ahead from remote
function git_commits_ahead() {
- if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
- local COMMITS
- COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
+ if $(command git rev-parse --git-dir > /dev/null 2>&1); then
+ local COMMITS="$(git rev-list --count @{upstream}..HEAD)"
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi
}