Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Improve vcs_info example for ahead/behind git commits
- X-seq: zsh-workers 48525
- From: Tim Lee <progscriptclone@xxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Cc: Lawrence Velázquez <larryv@xxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: [PATCH] Improve vcs_info example for ahead/behind git commits
- Date: Tue, 13 Apr 2021 19:58:30 +0800
- Archived-at: <https://zsh.org/workers/48525>
- In-reply-to: <20210413113441.GD6819@tarpaulin.shahaf.local2>
- List-id: <zsh-workers.zsh.org>
- References: <20210328213628.7rwz62bq5p2isd6b@home-guest> <20210329070611.GM18178@tarpaulin.shahaf.local2> <20210329093056.fegqam75id4yfkiq@home-guest> <ff17d1f9-d6ff-49bb-83d2-de0978ec61d4@www.fastmail.com> <20210329103927.qzky3fyevptfflvj@home-guest> <1b0343d9-87c2-4a0d-860f-30a390d7034d@www.fastmail.com> <87d2c775-18f3-4664-9a3f-de62f5b71777@www.fastmail.com> <20210413113441.GD6819@tarpaulin.shahaf.local2>
> 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