Handle non-readable .git dirs.

This can happen when a normal user edits/views some files in /etc, which
is maintained using git/etckeeper, and /etc/.git is only readable by
root.
This commit is contained in:
Daniel Hahler 2011-03-29 19:48:40 +02:00 committed by Tim Pope
parent 3026076ab5
commit 4b69204679

View File

@ -108,7 +108,7 @@ function! s:ExtractGitDir(path) abort
let ofn = ""
let nfn = fn
while fn != ofn
if isdirectory(fn . '/.git')
if filereadable(fn . '/.git/HEAD')
return s:sub(simplify(fnamemodify(fn . '/.git',':p')),'\W$','')
elseif fn =~ '\.git$' && filereadable(fn . '/HEAD')
return s:sub(simplify(fnamemodify(fn,':p')),'\W$','')