commit 67efbf66e0fcfd25e617d22892a7e9768bfd0f92 (tree)
parent eed46c1f24f91a0819c312dde1f34503d7906074
Author: Tim Pope <code@tpope.net>
Date: Wed, 27 Nov 2019 15:20:36 -0500
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
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
@@ -181,6 +181,8 @@ function! FugitiveExtractGitDir(path) abort
let path = s:Slash(a:path)
if path =~# '^fugitive:'
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
+ elseif empty(path)
+ return ''
elseif isdirectory(path)
let path = fnamemodify(path, ':p:s?/$??')
else