Fix interpretation of :% when % is absolute

We're trying to support two different Git syntaxes here that were never
meant to be mixed.  We want :/foo/bar to be interpreted as the pathspec
:(top)foo/bar, but we want :% to be interpreted as the % file in the
index, even when % is /foo/bar.

Resolves: https://github.com/tpope/vim-fugitive/issues/2404
This commit is contained in:
Tim Pope
2025-06-19 14:30:42 -04:00
parent 4a745ea72f
commit 593f831d6f

View File

@@ -2071,6 +2071,8 @@ function! s:Expand(rev, ...) abort
endif
elseif s:Slash(a:rev) =~# '^\a\a\+://'
let file = substitute(a:rev, '\\\@<!\%(#\a\|%\x\x\)', '\\&', 'g')
elseif a:rev =~# '^:[!#%$]'
let file = ':0' . a:rev
else
let file = a:rev
endif