User-specified branch name should not be empty

This commit is contained in:
Junegunn Choi 2020-08-29 01:38:33 +09:00
parent 588467903b
commit 6fa6475fee

View File

@ -646,25 +646,25 @@ function! s:parse_options(arg)
endif endif
let opts.tag = a:arg let opts.tag = a:arg
elseif type == s:TYPE.dict elseif type == s:TYPE.dict
call extend(opts, a:arg)
for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as'] for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as']
if has_key(opts, opt) if has_key(a:arg, opt)
\ && (type(opts[opt]) != s:TYPE.string || (opt != 'branch' && empty(opts[opt]))) \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt]))
throw printf(opt_errfmt, opt, 'string') throw printf(opt_errfmt, opt, 'string')
endif endif
endfor endfor
for opt in ['on', 'for'] for opt in ['on', 'for']
if has_key(opts, opt) if has_key(a:arg, opt)
\ && type(opts[opt]) != s:TYPE.list \ && type(a:arg[opt]) != s:TYPE.list
\ && (type(opts[opt]) != s:TYPE.string || empty(opts[opt])) \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt]))
throw printf(opt_errfmt, opt, 'string or list') throw printf(opt_errfmt, opt, 'string or list')
endif endif
endfor endfor
if has_key(opts, 'do') if has_key(a:arg, 'do')
\ && type(opts.do) != s:TYPE.funcref \ && type(a:arg.do) != s:TYPE.funcref
\ && (type(opts.do) != s:TYPE.string || empty(opts.do)) \ && (type(a:arg.do) != s:TYPE.string || empty(a:arg.do))
throw printf(opt_errfmt, 'do', 'string or funcref') throw printf(opt_errfmt, 'do', 'string or funcref')
endif endif
call extend(opts, a:arg)
if has_key(opts, 'dir') if has_key(opts, 'dir')
let opts.dir = s:dirpath(s:plug_expand(opts.dir)) let opts.dir = s:dirpath(s:plug_expand(opts.dir))
endif endif