mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-15 14:53:51 -05:00
Support default value as third FugitiveConfigGet() argument
This commit is contained in:
@@ -623,9 +623,10 @@ let s:config = {}
|
||||
function! fugitive#Config(...) abort
|
||||
let dir = s:Dir()
|
||||
let name = ''
|
||||
let default = get(a:, 3, '')
|
||||
if a:0 >= 2 && type(a:2) == type({})
|
||||
let name = substitute(a:1, '^[^.]\+\|[^.]\+$', '\L&', 'g')
|
||||
return len(a:1) ? get(get(a:2, name, []), 0, '') : a:2
|
||||
return len(a:1) ? get(get(a:2, name, []), 0, default) : a:2
|
||||
elseif a:0 >= 2
|
||||
let dir = a:2
|
||||
let name = a:1
|
||||
@@ -660,7 +661,7 @@ function! fugitive#Config(...) abort
|
||||
let s:config[dir_key] = [s:ConfigTimestamps(dir, dict), dict]
|
||||
lockvar! dict
|
||||
endif
|
||||
return len(name) ? get(get(dict, name, []), 0, '') : dict
|
||||
return len(name) ? get(get(dict, name, []), 0, default) : dict
|
||||
endfunction
|
||||
|
||||
function! s:Remote(dir) abort
|
||||
|
||||
@@ -128,8 +128,8 @@ endfunction
|
||||
" structure of the return value as it is not guaranteed. If you want a full
|
||||
" dictionary of every config value, use FugitiveConfigGetRegexp('.*').
|
||||
function! FugitiveConfig(...) abort
|
||||
if a:0 == 2 && (type(a:2) != type({}) || has_key(a:2, 'git_dir'))
|
||||
return fugitive#Config(a:1, FugitiveGitDir(a:2))
|
||||
if a:0 >= 2 && (type(a:2) != type({}) || has_key(a:2, 'git_dir'))
|
||||
return call('fugitive#Config', [a:1, FugitiveGitDir(a:2)] + a:000[2:-1])
|
||||
elseif a:0 == 1 && (type(a:1) !=# type('') || a:1 !~# '^[[:alnum:]-]\+\.')
|
||||
return fugitive#Config(FugitiveGitDir(a:1))
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user