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)
elseif type !=# '' && filereadable(dir)
let line = get(readfile(dir, '', 1), 0, '')
if line =~# '^gitdir: \.' && FugitiveIsGitDir(root.'/'.line[8:-1])
return simplify(root.'/'.line[8:-1])
elseif line =~# '^gitdir: ' && FugitiveIsGitDir(line[8:-1])
return line[8:-1]
let file_dir = matchstr(line, '^gitdir: \zs.*')
if file_dir !~# '^/\|^\a:' && FugitiveIsGitDir(root . '/' . file_dir)
return simplify(root . '/' . file_dir)
elseif len(file_dir) && FugitiveIsGitDir(file_dir)
return file_dir
endif
elseif FugitiveIsGitDir(root)
return root