mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 21:33:53 -05:00
Support most top level Git options
This commit is contained in:
@@ -2413,39 +2413,53 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
||||
let config = copy(fugitive#Config(dir))
|
||||
let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir))
|
||||
let flags = []
|
||||
while len(args) > 1
|
||||
if args[0] ==# '-c'
|
||||
let pager = -1
|
||||
while len(args)
|
||||
if args[0] ==# '-c' && len(args) > 1
|
||||
call extend(flags, remove(args, 0, 1))
|
||||
elseif args[0] =~# '^-p$\|^--paginate$'
|
||||
let pager = 1
|
||||
call remove(args, 0)
|
||||
elseif args[0] =~# '^-P$\|^--no-pager$'
|
||||
let pager = 0
|
||||
call remove(args, 0)
|
||||
elseif args[0] =~# '^--\%([[:lower:]-]\+-pathspecs\|no-optional-locks\)$'
|
||||
call add(flags, remove(args, 0))
|
||||
elseif args[0] =~# '^-C$\|^--\%(exec-path=\|git-dir=\|work-tree=\|bare$\)'
|
||||
return 'echoerr ' . string('fugitive: ' . args[0] . ' is not supported')
|
||||
else
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
if empty(args)
|
||||
if pager is# 0
|
||||
call add(flags, '--no-pager')
|
||||
endif
|
||||
if empty(args) && pager is# -1
|
||||
let cmd = s:StatusCommand(a:line1, a:line2, a:range, a:line2, a:bang, a:mods, '', '', [])
|
||||
return (empty(cmd) ? 'exe' : cmd) . after
|
||||
endif
|
||||
let alias = get(s:Aliases(dir), args[0], '!')
|
||||
if get(args, 1, '') !=# '--help' && alias !~# '^!\|[\"'']' && !filereadable(s:ExecPath() . '/git-' . args[0])
|
||||
let alias = fugitive#Config('alias.' . get(args, 0, ''), config)
|
||||
if get(args, 1, '') !=# '--help' && alias !~# '^$\|^!\|[\"'']' && !filereadable(s:ExecPath() . '/git-' . args[0])
|
||||
\ && !(has('win32') && filereadable(s:ExecPath() . '/git-' . args[0] . '.exe'))
|
||||
call remove(args, 0)
|
||||
call extend(args, split(alias, '\s\+'), 'keep')
|
||||
endif
|
||||
let name = substitute(args[0], '\%(^\|-\)\(\l\)', '\u\1', 'g')
|
||||
let name = substitute(get(args, 0, ''), '\%(^\|-\)\(\l\)', '\u\1', 'g')
|
||||
let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+')
|
||||
let options = {'git': git, 'dir': dir, 'flags': flags}
|
||||
if exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help'
|
||||
if pager is# -1 && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help'
|
||||
try
|
||||
let overrides = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, extend({'command': args[0], 'args': args[1:-1]}, options))
|
||||
if type(overrides) == type('')
|
||||
return 'exe ' . string(overrides) . after
|
||||
endif
|
||||
let args = [get(overrides, 'command', args[0])] + get(overrides, 'insert_args', []) + args[1:-1]
|
||||
catch /^fugitive:/
|
||||
return 'echoerr ' . string(v:exception)
|
||||
endtry
|
||||
else
|
||||
let overrides = {}
|
||||
endif
|
||||
let args = [get(overrides, 'command', args[0])] + get(overrides, 'insert_args', []) + args[1:-1]
|
||||
let env = get(overrides, 'env', {})
|
||||
let i = 0
|
||||
while i < len(flags) - 1
|
||||
@@ -2464,15 +2478,13 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
||||
let i += 1
|
||||
endwhile
|
||||
let editcmd = (a:line2 > 0 ? a:line2 : '') . (a:line2 ? 'split' : 'edit')
|
||||
if args[0] =~# '^-p$\|^--paginate$'
|
||||
call remove(args, 0)
|
||||
let pager = 1
|
||||
if pager is# 1
|
||||
if a:bang && a:line2 >= 0
|
||||
let editcmd = 'read'
|
||||
elseif a:bang
|
||||
let editcmd = 'pedit'
|
||||
endif
|
||||
else
|
||||
elseif pager is# -1
|
||||
let pager = fugitive#PagerFor(args, config)
|
||||
if a:bang && pager isnot# 1
|
||||
return 'echoerr ' . string('fugitive: :Git! for temp buffer output has been replaced by :Git --paginate')
|
||||
|
||||
Reference in New Issue
Block a user