From 8920453f5d1641ed44bd1b9ca53b9ab6afa44208 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 31 Aug 2021 17:43:07 -0400 Subject: [PATCH] Return full ref name on FugitiveHead(-1) --- autoload/fugitive.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 1b8afe3..42105f8 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -925,11 +925,15 @@ function! fugitive#Head(...) abort let s:head_cache[file] = [ftime, readfile(file)[0]] endif let head = s:head_cache[file][1] + let len = a:0 ? a:1 : 0 if head =~# '^ref: ' - return substitute(head, '\C^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '') + if len < 0 + return strpart(head, 5) + else + return substitute(head, '\C^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '') + endif elseif head =~# '^\x\{40,\}$' - let len = a:0 ? a:1 : 0 - return len < 0 ? head : len ? head[0:len-1] : '' + return len < 0 ? head : strpart(head, 0, len) else return '' endif