about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTim Lee <progscriptclone@gmail.com>2021-04-13 19:58:30 +0800
committerDaniel Shahaf <d.s@daniel.shahaf.name>2021-04-13 13:55:48 +0000
commit3b631babec67c15c893c0d31f8aaaaaa06ca8cfa (patch)
treec6a3832b40c9e75c9bbc11f730b4cb118175b75d
parenta90d5ab90191c3681f9216579d2e134314cd8cd7 (diff)
downloadzsh-3b631babec67c15c893c0d31f8aaaaaa06ca8cfa.tar.gz
zsh-3b631babec67c15c893c0d31f8aaaaaa06ca8cfa.tar.xz
zsh-3b631babec67c15c893c0d31f8aaaaaa06ca8cfa.zip
48525: vcs_info git docs: ahead/behind commits: Run fewer external programs
-rw-r--r--ChangeLog5
-rw-r--r--Misc/vcs_info-examples8
2 files changed, 7 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 5ef3e1752..064b13c55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-13  Tim Lee  <progscriptclone@gmail.com>
+
+	* 48525: Misc/vcs_info-examples: vcs_info git docs: ahead/behind
+	commits: Run fewer external programs
+
 2021-04-12  Jun-ichi Takimoto  <takimoto-j@kba.biglobe.ne.jp>
 
 	* 48439: Src/mem.c: remove macros that became unnecessary by 47785
diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples
index 94b8a7b5e..d33d0ceed 100644
--- a/Misc/vcs_info-examples
+++ b/Misc/vcs_info-examples
@@ -179,14 +179,10 @@ function +vi-git-st() {
     local ahead behind
     local -a gitstatus
 
-    # for git prior to 1.7
-    # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
-    ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
+    ahead=$(git rev-list --count ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null)
     (( $ahead )) && gitstatus+=( "+${ahead}" )
 
-    # for git prior to 1.7
-    # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
-    behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
+    behind=$(git rev-list --count HEAD..${hook_com[branch]}@{upstream} 2>/dev/null)
     (( $behind )) && gitstatus+=( "-${behind}" )
 
     hook_com[misc]+=${(j:/:)gitstatus}