Resolve symlinks in configured work tree

Closes https://github.com/tpope/vim-fugitive/issues/1382
This commit is contained in:
Tim Pope
2019-10-22 05:13:42 -04:00
parent 395d947644
commit b09c5d2523

View File

@@ -157,16 +157,16 @@ function! s:Tree(path) abort
let config = readfile(config_file,'',10) let config = readfile(config_file,'',10)
call filter(config,'v:val =~# "^\\s*worktree *="') call filter(config,'v:val =~# "^\\s*worktree *="')
if len(config) == 1 if len(config) == 1
let worktree = s:Slash(FugitiveVimPath(matchstr(config[0], '= *\zs.*'))) let worktree = FugitiveVimPath(matchstr(config[0], '= *\zs.*'))
endif endif
elseif filereadable(dir . '/gitdir') elseif filereadable(dir . '/gitdir')
let worktree = s:Slash(fnamemodify(FugitiveVimPath(readfile(dir . '/gitdir')[0]), ':h')) let worktree = fnamemodify(FugitiveVimPath(readfile(dir . '/gitdir')[0]), ':h')
if worktree ==# '.' if worktree ==# '.'
unlet! worktree unlet! worktree
endif endif
endif endif
if exists('worktree') if exists('worktree')
let s:worktree_for_dir[dir] = worktree let s:worktree_for_dir[dir] = s:Slash(resolve(worktree))
let s:dir_for_worktree[s:worktree_for_dir[dir]] = dir let s:dir_for_worktree[s:worktree_for_dir[dir]] = dir
endif endif
endif endif