Commit 61981951 authored by Steven's avatar Steven Committed by Marc Cornellà
Browse files

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
parent a7e30b26
...@@ -76,9 +76,8 @@ function git_current_branch() { ...@@ -76,9 +76,8 @@ function git_current_branch() {
# Gets the number of commits ahead from remote # Gets the number of commits ahead from remote
function git_commits_ahead() { function git_commits_ahead() {
if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then if $(command git rev-parse --git-dir > /dev/null 2>&1); then
local COMMITS local COMMITS="$(git rev-list --count @{upstream}..HEAD)"
COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi fi
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment