From c0488d20847f97e02596c84fd4246b0c7010ac00 Mon Sep 17 00:00:00 2001 From: Steven Spasbo Date: Fri, 2 Oct 2015 18:37:21 -0700 Subject: [PATCH] Added git_commits_behind function --- lib/git.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/git.zsh b/lib/git.zsh index 1c76d5882..926fd7985 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -83,6 +83,13 @@ function git_commits_ahead() { fi } +# Gets the number of commits behind remote +function git_commits_behind() { + if git rev-parse --git-dir > /dev/null 2>&1; then + echo $(git rev-list --count $(current_branch)..$(git rev-parse --abbrev-ref --symbolic-full-name @{u})) + fi +} + # Outputs if current branch is ahead of remote function git_prompt_ahead() { if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then