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 1b811b88a4.

Resolves: https://github.com/tpope/vim-fugitive/issues/1978
Resolves: https://github.com/tpope/vim-fugitive/issues/1979
This commit is contained in:
Tim Pope
2022-04-20 23:25:14 -04:00
parent 1b811b88a4
commit b04708af2d

View File

@@ -413,10 +413,9 @@ function! FugitiveExtractGitDir(path) abort
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)') return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
elseif empty(path) elseif empty(path)
return '' return ''
elseif path !~# '^/\|^\a\+:' else
let path = s:Slash(getcwd()) . '/' . path let path = fnamemodify(path, ':p:h')
endif endif
let path = fnamemodify(path, ':h')
let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '') let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '')
if len(pre) && exists('*' . pre . 'Real') if len(pre) && exists('*' . pre . 'Real')
let path ={pre}Real(path) let path ={pre}Real(path)