commit 4ecd7e893200b0552a5cbaba0dc0b0831febb8fc (tree)
parent 73220820b5eb399d29067f114888da0d8e1e08da
Author: Tim Pope <code@tpope.net>
Date: Fri, 21 Dec 2018 13:23:30 -0500
Allow reusing dictionary for config queries
Diffstat:
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -341,13 +341,17 @@ let s:config = {}
function! fugitive#Config(...) abort
let dir = get(b:, 'git_dir', '')
let name = ''
- if len(a:000) >= 2
- let dir = a:000[1]
- let name = a:000[0]
- elseif len(a:000) == 1 && a:000[0] =~# '^[[:alnum:]-]\+\.'
- let name = a:000[0]
- elseif len(a:000) == 1
- let dir = a:000[0]
+ if a:0 >= 2 && type(a:2) == type({})
+ return len(a:1) ? get(get(a:2, a:1, []), 0, '') : a:2
+ elseif a:0 >= 2
+ let dir = a:2
+ let name = a:1
+ elseif a:0 == 1 && type(a:1) == type({})
+ return a:1
+ elseif a:0 == 1 && a:1 =~# '^[[:alnum:]-]\+\.'
+ let name = a:1
+ elseif a:0 == 1
+ let dir = a:1
endif
let key = len(dir) ? dir : '_'
if has_key(s:config, key) && s:config[key][0] ==# s:ConfigTimestamps(dir, s:config[key][1])
diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
@@ -73,10 +73,10 @@ function! FugitivePrepare(...) abort
endfunction
function! FugitiveConfig(...) abort
- if len(a:000) == 2
- return fugitive#Config(a:000[1], FugitiveGitDir(a:000[2]))
- elseif len(a:000) == 1 && a:000[0] !~# '^[[:alnum:]-]\+\.'
- return fugitive#Config(FugitiveGitDir(a:000[0]))
+ if a:0 == 2 && type(a:2) != type({})
+ return fugitive#Config(a:1, FugitiveGitDir(a:2))
+ elseif a:0 == 1 && a:1 !~# '^[[:alnum:]-]\+\.'
+ return fugitive#Config(FugitiveGitDir(a:1))
else
return call('fugitive#Config', a:000)
endif