From b04708af2dd94197a5636f26f32c514262483e7a Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 20 Apr 2022 23:25:14 -0400 Subject: [PATCH] Revert "Avoid IO from ":p" during detection" This change failed to account for the directory edge case, where ":p:h" has the very nice property of giving us back the original input, due to ":p" appending a trailing slash. Without this, we fail to detect when editing the root of the repository. This reverts commit 1b811b88a45ff7b906ea9314adf016883ce5cd9e. Resolves: https://github.com/tpope/vim-fugitive/issues/1978 Resolves: https://github.com/tpope/vim-fugitive/issues/1979 --- plugin/fugitive.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index ed5c959..2ec473f 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -413,10 +413,9 @@ function! FugitiveExtractGitDir(path) abort return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)') elseif empty(path) return '' - elseif path !~# '^/\|^\a\+:' - let path = s:Slash(getcwd()) . '/' . path + else + let path = fnamemodify(path, ':p:h') endif - let path = fnamemodify(path, ':h') let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '') if len(pre) && exists('*' . pre . 'Real') let path ={pre}Real(path)