Cache configured worktree

Note that the repo object holding the cached value is short lived.
This commit is contained in:
Tim Pope 2012-03-18 22:22:28 -04:00
parent c5cd0c96f7
commit dfb10448e2

View File

@ -203,14 +203,17 @@ function! s:repo_dir(...) dict abort
endfunction
function! s:repo_configured_tree() dict abort
if !has_key(self,'_tree')
let self._tree = ''
if filereadable(self.dir('config'))
let config = readfile(self.dir('config'),10)
call filter(config,'v:val =~# "^\\s*worktree *="')
if len(config) == 1
return matchstr(config[0], '= *\zs.*')
let self._tree = matchstr(config[0], '= *\zs.*')
endif
endif
return ''
endif
return self._tree
endfunction
function! s:repo_tree(...) dict abort