From 67efbf66e0fcfd25e617d22892a7e9768bfd0f92 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 27 Nov 2019 15:20:36 -0500 Subject: [PATCH] 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 --- plugin/fugitive.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index be3b99b..99b78f1 100644 --- 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