Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Improve vcs_info example for ahead/behind git commits



> Tim: Would you have time to address the remaining points from the
> original review, https://zsh.org/workers/48306, either by implementing
> them and sending a revised patch, or by counterarguing them?

I think I'll just porpose something simple, since I'm not very familiar
with ZSH.

Patch:

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}




Messages sorted by: Reverse Date, Date, Thread, Author