about summary refs log tree commit diff
path: root/Misc/vcs_info-examples
diff options
context:
space:
mode:
Diffstat (limited to 'Misc/vcs_info-examples')
-rw-r--r--Misc/vcs_info-examples3
1 files changed, 3 insertions, 0 deletions
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}" )