Expand simple aliases in :Git

This lets you alias ca = `git commit -a` and have `:Git ca` call
`:Gcommit -a`.
This commit is contained in:
Tim Pope 2019-08-07 17:31:08 -04:00
parent edae34e02f
commit cfca94c723

View File

@ -2109,6 +2109,11 @@ function! s:GitCommand(line1, line2, range, count, bang, mods, reg, arg, args) a
let cmd = s:StatusCommand(a:line1, a:line2, a:range, a:count, a:bang, a:mods, a:reg, '', []) let cmd = s:StatusCommand(a:line1, a:line2, a:range, a:count, a:bang, a:mods, a:reg, '', [])
return (empty(cmd) ? 'exe' : cmd) . after return (empty(cmd) ? 'exe' : cmd) . after
endif endif
let alias = get(s:Aliases(dir), args[0], '!')
if alias !~# '^!\|[\"'']' && !filereadable(s:ExecPath() . '/git-' . args[0])
call remove(args, 0)
call extend(args, split(alias, '\s\+'), 'keep')
endif
let name = substitute(args[0], '\%(^\|-\)\(\l\)', '\u\1', 'g') let name = substitute(args[0], '\%(^\|-\)\(\l\)', '\u\1', 'g')
if exists('*s:' . name . 'Subcommand') if exists('*s:' . name . 'Subcommand')
try try