Make RemoteUrl() option parsing a bit less convoluted

This commit is contained in:
Tim Pope
2021-09-14 03:33:36 -04:00
parent 529311cec7
commit ba52c2b446

View File

@@ -1266,19 +1266,16 @@ function! s:ConfigLengthSort(i1, i2) abort
endfunction endfunction
function! fugitive#RemoteUrl(...) abort function! fugitive#RemoteUrl(...) abort
let args = a:000 let args = copy(a:000)
if a:0 && (type(a:1) !=# type('') || a:1 =~# '^/\|^\a:[\\/]' && get(a:, 2, '') !~# '^/\|^\a:[\\/]') if len(args) && (type(args[0]) !=# type('') || args[0] =~# '^/\|^\a:[\\/]' && get(args, 1, '') !~# '^/\|^\a:[\\/]')
let config = fugitive#Config(a:1) let config = fugitive#Config(remote(args, 0))
let args = a:000[1:-1]
if type(a:1) ==# type({}) && has_key(a:1, 'remote_name') && (type(get(args, 0, 0)) !=# type('') || args[0] =~# '^:') if type(a:1) ==# type({}) && has_key(a:1, 'remote_name') && (type(get(args, 0, 0)) !=# type('') || args[0] =~# '^:')
call insert(args, a:1.remote_name) call insert(args, a:1.remote_name)
endif endif
elseif a:0 > 1 && type(a:2) ==# type({}) || (type(a:2) ==# type('') && a:2 !~# '^:') elseif len(args) > 1 && (type(args[1]) !=# type('') || args[1] !~# '^:')
let config = fugitive#Config(a:2) let config = fugitive#Config(remove(args, 1))
let args = [a:1] + a:000[2:-1]
else else
let config = fugitive#Config() let config = fugitive#Config()
let args = copy(a:000)
endif endif
if empty(args) || args[0] =~# '^:' if empty(args) || args[0] =~# '^:'
let url = s:Remote(config) let url = s:Remote(config)