From d9ac5916ba17889abf094c1ac45d88f431338d9c Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 13 Apr 2021 13:56:36 +0000 Subject: [PATCH] 48528/0001: vcs_info git docs: ahead/behind commits: Don't run rev-list when that would fail --- ChangeLog | 5 +++++ Misc/vcs_info-examples | 3 +++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6364ed067..a7658fbcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2021-04-20 Daniel Shahaf + + * 48528/0001: Misc/vcs_info-examples: vcs_info git docs: + ahead/behind commits: Don't run rev-list when that would fail + 2021-04-19 Bart Schaefer * 48617: Completion/Base/Widget/_complete_debug: fix misuse of diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index d33d0ceed..065ea6cb3 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -179,6 +179,9 @@ function +vi-git-st() { local ahead behind local -a gitstatus + # Exit early in case the worktree is on a detached HEAD + git rev-parse ${hook_com[branch]}@{upstream} >/dev/null 2>&1 || return 0 + ahead=$(git rev-list --count ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null) (( $ahead )) && gitstatus+=( "+${ahead}" )