commit dfb10448e202fbca85617675907c308db7895e8f (tree)
parent c5cd0c96f7cff8cabf9733ff5e1cd093a3f2f348
Author: Tim Pope <code@tpope.net>
Date: Sun, 18 Mar 2012 22:22:28 -0400
Cache configured worktree
Note that the repo object holding the cached value is short lived.
Diffstat:
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
@@ -203,14 +203,17 @@ function! s:repo_dir(...) dict abort
endfunction
function! s:repo_configured_tree() dict abort
- 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.*')
+ 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
+ let self._tree = matchstr(config[0], '= *\zs.*')
+ endif
endif
endif
- return ''
+ return self._tree
endfunction
function! s:repo_tree(...) dict abort