From fea5f616d17b11446a48327b6719180adf577425 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sat, 3 Nov 2018 03:08:32 +0100 Subject: [PATCH] Get branch name from VCS_INFO subsystem when collecting ahead/behind info --- functions/vcs.zsh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/functions/vcs.zsh b/functions/vcs.zsh index 1478e0e2..50a77d49 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -26,19 +26,17 @@ function +vi-git-untracked() { } function +vi-git-aheadbehind() { - local ahead behind branch_name + local ahead behind local -a gitstatus - branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) - # for git prior to 1.7 - # ahead=$(command git rev-list origin/${branch_name}..HEAD | wc -l) - ahead=$(command git rev-list --count "${branch_name}"@{upstream}..HEAD 2>/dev/null) + # ahead=$(command git rev-list origin/${hook_com[branch]}..HEAD | wc -l) + ahead=$(command git rev-list --count "${hook_com[branch]}"@{upstream}..HEAD 2>/dev/null) (( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" ) # for git prior to 1.7 - # behind=$(command git rev-list HEAD..origin/${branch_name} | wc -l) - behind=$(command git rev-list --count HEAD.."${branch_name}"@{upstream} 2>/dev/null) + # behind=$(command git rev-list HEAD..origin/${hook_com[branch]} | wc -l) + behind=$(command git rev-list --count HEAD.."${hook_com[branch]}"@{upstream} 2>/dev/null) (( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" ) hook_com[misc]+=${(j::)gitstatus}