Clean up gitdir file parsing

This commit is contained in:
Tim Pope 2019-08-15 02:21:30 -04:00
parent 6eb885c017
commit faa895239b

View File

@ -184,10 +184,11 @@ function! FugitiveExtractGitDir(path) abort
return resolve(dir) return resolve(dir)
elseif type !=# '' && filereadable(dir) elseif type !=# '' && filereadable(dir)
let line = get(readfile(dir, '', 1), 0, '') let line = get(readfile(dir, '', 1), 0, '')
if line =~# '^gitdir: \.' && FugitiveIsGitDir(root.'/'.line[8:-1]) let file_dir = matchstr(line, '^gitdir: \zs.*')
return simplify(root.'/'.line[8:-1]) if file_dir !~# '^/\|^\a:' && FugitiveIsGitDir(root . '/' . file_dir)
elseif line =~# '^gitdir: ' && FugitiveIsGitDir(line[8:-1]) return simplify(root . '/' . file_dir)
return line[8:-1] elseif len(file_dir) && FugitiveIsGitDir(file_dir)
return file_dir
endif endif
elseif FugitiveIsGitDir(root) elseif FugitiveIsGitDir(root)
return root return root