From 96a2092e377139fbcd95d7b7ac703b740daa22f6 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 15 Jul 2016 02:05:39 -0700 Subject: [PATCH] lib/git.zsh: Added git_commits_behind function (#4450) * Added git_commits_behind function * Added 'command' to git_commits_behind function * git_commits_behind code review changes --- lib/git.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/git.zsh b/lib/git.zsh index 1c76d58829ba..c79cc0d8e38c 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 $(command git rev-parse --git-dir > /dev/null 2>&1); then + echo $(git rev-list --count HEAD..@{upstream}) + 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