diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index cfba5e6..cad6ef7 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2018,9 +2018,6 @@ augroup END " Section: :Git -call s:command("-bang -nargs=? -range=-1 -complete=customlist,fugitive#CompleteGit Git", "Git") -call s:command("-bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteGit G", "") - function! s:GitExec(line1, line2, range, count, bang, mods, reg, args, dir) abort if empty(a:args) return s:StatusCommand(a:line1, a:line2, a:range, a:count, a:bang, a:mods, a:reg, '', []) @@ -2058,8 +2055,8 @@ endfunction function! s:Command(line1, line2, range, count, bang, mods, reg, arg, args, ...) abort let dir = a:0 ? s:Dir(a:1) : s:Dir() - let args = s:SplitExpand(a:arg, s:Tree(dir)) - return s:GitExec(a:line1, a:line2, a:range, a:count, a:bang, a:mods, a:reg, args, dir) + let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir)) + return s:GitExec(a:line1, a:line2, a:range, a:count, a:bang, a:mods, a:reg, args, dir) . after endfunction let s:exec_paths = {} @@ -2103,6 +2100,9 @@ function! fugitive#Complete(...) abort return call('fugitive#CompleteGit', a:000) endfunction +call s:command("-bang -nargs=? -range=-1 -complete=customlist,fugitive#CompleteGit Git", "Git") +call s:command("-bang -nargs=? -range=-1 -complete=customlist,fugitive#CompleteGit G", "") + " Section: :Gcd, :Glcd function! s:DirComplete(A, L, P) abort @@ -3168,9 +3168,9 @@ function! s:RebaseEdit(cmd, dir) abort return a:cmd . ' +setlocal\ bufhidden=wipe\|' . escape('let b:fugitive_rebase_shas = ' . string(shas), ' ') . ' ' . rebase_todo endfunction -function! s:Merge(cmd, bang, mods, args, ...) abort +function! s:MergeRebase(cmd, bang, mods, args, ...) abort let dir = a:0 ? a:1 : s:Dir() - let args = s:SplitExpand(a:args, s:Tree(dir)) + let args = a:args let mods = s:Mods(a:mods) if a:cmd =~# '^rebase' && s:HasOpt(args, '-i', '--interactive') let cmd = fugitive#Prepare(dir, '-c', 'sequence.editor=sh ' . s:RebaseSequenceAborter(), 'rebase') . ' ' . s:shellesc(args) @@ -3184,7 +3184,7 @@ function! s:Merge(cmd, bang, mods, args, ...) abort endfor call writefile([], fugitive#Find('.git/rebase-merge/done', dir)) if a:bang - return '' + return 'exe' endif return s:RebaseEdit(mods . 'split', dir) elseif a:cmd =~# '^rebase' && s:HasOpt(args, '--edit-todo') && filereadable(fugitive#Find('.git/rebase-merge/git-rebase-todo', dir)) @@ -3300,7 +3300,7 @@ function! s:Merge(cmd, bang, mods, args, ...) abort return 'cfirst' endif endif - return exists('err') ? 'echoerr '.string(err) : '' + return exists('err') ? 'echoerr '.string(err) : 'exe' endfunction function! s:RebaseClean(file) abort @@ -3324,6 +3324,21 @@ function! s:RebaseClean(file) abort return '' endfunction +function! s:MergeCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort + let [args, after] = s:SplitExpandChain(a:arg, s:Tree()) + return s:MergeRebase('merge', a:bang, a:mods, args) . after +endfunction + +function! s:RebaseCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort + let [args, after] = s:SplitExpandChain(a:arg, s:Tree()) + return s:MergeRebase('rebase', a:bang, a:mods, args) . after +endfunction + +function! s:PullCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort + let [args, after] = s:SplitExpandChain(a:arg, s:Tree()) + return s:MergeRebase('pull --progress', a:bang, a:mods, args) . after +endfunction + augroup fugitive_merge autocmd! autocmd VimLeavePre,BufDelete git-rebase-todo @@ -3335,16 +3350,13 @@ augroup fugitive_merge \ endif autocmd BufEnter * nested \ if exists('s:rebase_continue') | - \ exe s:Merge('rebase', 0, '', getfsize(fugitive#Find('.git/rebase-merge/git-rebase-todo', s:rebase_continue)) > 0 ? '--continue' : '--abort', remove(s:, 'rebase_continue')) | + \ exe s:MergeRebase('rebase', 0, '', [getfsize(fugitive#Find('.git/rebase-merge/git-rebase-todo', s:rebase_continue)) > 0 ? '--continue' : '--abort'], remove(s:, 'rebase_continue')) | \ endif augroup END -call s:command("-nargs=? -bar -bang -complete=customlist,s:MergeComplete Gmerge " . - \ "execute s:Merge('merge', 0, '', )") -call s:command("-nargs=? -bar -bang -complete=customlist,s:RebaseComplete Grebase " . - \ "execute s:Merge('rebase', 0, '', )") -call s:command("-nargs=? -bar -bang -complete=customlist,s:PullComplete Gpull " . - \ "execute s:Merge('pull --progress', 0, '', )") +call s:command("-nargs=? -bang -complete=customlist,s:MergeComplete Gmerge", "Merge") +call s:command("-nargs=? -bang -complete=customlist,s:RebaseComplete Grebase", "Rebase") +call s:command("-nargs=? -bang -complete=customlist,s:PullComplete Gpull", "Pull") " Section: :Ggrep, :Glog @@ -3418,7 +3430,7 @@ function! s:Grep(type, bang, arg) abort if fugitive#GitVersion(2, 19) call add(cmd, '--column') endif - let args = s:SplitExpand(a:arg, s:Tree(dir)) + let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir)) if exists(':chistory') call s:SetLocList(listnr, [], ' ', {'title': (listnr < 0 ? ':Ggrep ' : ':Glgrep ') . s:fnameescape(args)}) else @@ -3432,16 +3444,16 @@ function! s:Grep(type, bang, arg) abort let list = map(readfile(tempfile), 's:GrepParseLine(cached, name_only, dir, v:val)') call s:SetLocList(listnr, list, 'a') if !a:bang && !empty(list) - return (listnr < 0 ? 'c' : 'l').'first' + return (listnr < 0 ? 'c' : 'l').'first' . after else - return '' + return after[1:-1] endif endfunction function! s:Log(type, bang, line1, count, args) abort let dir = s:Dir() let listnr = a:type =~# '^l' ? 0 : -1 - let args = s:SplitExpand(a:args, s:Tree(dir)) + let [args, after] = s:SplitExpandChain(a:args, s:Tree(dir)) let split = index(args, '--') if split > 0 let paths = args[split : -1] @@ -3496,17 +3508,17 @@ function! s:Log(type, bang, line1, count, args) abort wincmd p endif if !a:bang && len(s:GetLocList(listnr)) - return a:type . 'first' + return a:type . 'first' . after endif - return '' + return after[1:-1] endfunction -call s:command("-bar -bang -nargs=? -complete=customlist,s:GrepComplete Ggrep :execute s:Grep('c',0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:GrepComplete Gcgrep :execute s:Grep('c',0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:Grep('l',0,)") -call s:command("-bar -bang -nargs=? -range=-1 -complete=customlist,s:LogComplete Glog :exe s:Log('c',0,,,)") -call s:command("-bar -bang -nargs=? -range=-1 -complete=customlist,s:LogComplete Gclog :exe s:Log('c',0,,,)") -call s:command("-bar -bang -nargs=? -range=-1 -complete=customlist,s:LogComplete Gllog :exe s:Log('l',0,,,)") +call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Ggrep :execute s:Grep('c',0,)") +call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Gcgrep :execute s:Grep('c',0,)") +call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:Grep('l',0,)") +call s:command("-bang -nargs=? -range=-1 -complete=customlist,s:LogComplete Glog :exe s:Log('c',0,,,)") +call s:command("-bang -nargs=? -range=-1 -complete=customlist,s:LogComplete Gclog :exe s:Log('c',0,,,)") +call s:command("-bang -nargs=? -range=-1 -complete=customlist,s:LogComplete Gllog :exe s:Log('l',0,,,)") " Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread