Skip to content

Commit

Permalink
Updated git_commits_ahead function (ohmyzsh#5247)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
stevenspasbo authored and mcornella committed Aug 1, 2016
1 parent a7e30b2 commit 6198195
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/git.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 6198195

Please sign in to comment.