From faa895239bca9192747c43cd9d1bc7ed44627788 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Thu, 15 Aug 2019 02:21:30 -0400 Subject: [PATCH] Clean up gitdir file parsing --- plugin/fugitive.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index c67b1a6..21d7b9a 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -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