96a2092e377139fbcd95d7b7ac703b740daa22f6

Author
Steven <stevenspasbo@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

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

Diff

 1diff --git a/lib/git.zsh b/lib/git.zsh
 2index 1c76d58829bae4e2e91f31d99938fce1c96de746..c79cc0d8e38c2bd485b5c6e0f85ee0c9508598fd 100644
 3--- a/lib/git.zsh
 4+++ b/lib/git.zsh
 5@@ -83,6 +83,13 @@ function git_commits_ahead() {
 6   fi
 7 }
 8 
 9+# Gets the number of commits behind remote
10+function git_commits_behind() {
11+  if $(command git rev-parse --git-dir > /dev/null 2>&1); then
12+    echo $(git rev-list --count HEAD..@{upstream})
13+  fi
14+}
15+
16 # Outputs if current branch is ahead of remote
17 function git_prompt_ahead() {
18   if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then