Don't reject invalid Git dir when detecting common dir

Consumers of this function should be giving us a valid Git dir, and if
they don't, returning an empty string will only make matters worse.

References: https://github.com/tpope/vim-fugitive/pull/1898
This commit is contained in:
Tim Pope
2021-12-01 19:58:06 -05:00
parent c666c86882
commit 2064312ad7

View File

@@ -478,9 +478,7 @@ function! fugitive#CommonDir(dir) abort
return '' return ''
endif endif
if !has_key(s:commondirs, a:dir) if !has_key(s:commondirs, a:dir)
if getfsize(a:dir . '/HEAD') < 10 if filereadable(a:dir . '/commondir') && getfsize(a:dir . '/HEAD') >= 10
let s:commondirs[a:dir] = ''
elseif filereadable(a:dir . '/commondir')
let cdir = get(readfile(a:dir . '/commondir', '', 1), 0, '') let cdir = get(readfile(a:dir . '/commondir', '', 1), 0, '')
if cdir =~# '^/\|^\a:/' if cdir =~# '^/\|^\a:/'
let s:commondirs[a:dir] = s:Slash(FugitiveVimPath(cdir)) let s:commondirs[a:dir] = s:Slash(FugitiveVimPath(cdir))