Don't fall back to pwd for Git dir of blank filename

In particular, this fixes `FugitiveFind(..., '')` to respect the empty
Git dir argument rather than falling back to detection on the current
working directory.  Which in turn fixes :Gstatus using the current
working directory when called from a buffer that does not belong to a
repository.

References https://github.com/tpope/vim-fugitive/issues/1408
This commit is contained in:
Tim Pope
2019-11-27 15:20:36 -05:00
parent eed46c1f24
commit 67efbf66e0

View File

@@ -181,6 +181,8 @@ function! FugitiveExtractGitDir(path) abort
let path = s:Slash(a:path) let path = s:Slash(a:path)
if path =~# '^fugitive:' if path =~# '^fugitive:'
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)') return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
elseif empty(path)
return ''
elseif isdirectory(path) elseif isdirectory(path)
let path = fnamemodify(path, ':p:s?/$??') let path = fnamemodify(path, ':p:s?/$??')
else else