From 49cc58573e746d02024110d9af99e95994ea4b72 Mon Sep 17 00:00:00 2001 From: Eric Milford Date: Wed, 23 Nov 2022 12:28:55 -0600 Subject: [PATCH] Tighten match for commit under cursor Using `coo` to open a branch under the cursor that started with 4+ hex digits (e.g., 1111-feat) would fail with the error `fatal: invalid reference: 1111.` This happened because the prior regex would consider these branch names as commits when determining whether to treat what was under the cursor as a branch or commit. This changes the regex to use a negative look-ahead to further tighten the match for a commit and require that a match on 4+ hex digits also not end with a non-hex digit. Resolves #2085. --- autoload/fugitive.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 315db95..eaac7f7 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -7553,7 +7553,7 @@ function! s:SquashArgument(...) abort if &filetype == 'fugitive' let commit = matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze \|^' . s:ref_header . ': \zs\S\+') elseif has_key(s:temp_files, s:cpath(expand('%:p'))) - let commit = matchstr(getline('.'), '\S\@') + let commit = matchstr(getline('.'), '\S\@