Allow reusing dictionary for config queries

This commit is contained in:
Tim Pope 2018-12-21 13:23:30 -05:00
parent 73220820b5
commit 4ecd7e8932
2 changed files with 15 additions and 11 deletions

View File

@ -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])

View File

@ -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