commit ee2b0ecdb80ec3e8d544e3f2f895275e0f76e292 (tree)
parent 94a5d6fe2f4f1abdabd97ffb243f8333bb20aa52
Author: Tim Pope <code@tpope.net>
Date: Mon, 30 Jun 2014 14:30:44 -0400
Provide :Gpush and :Gfetch
Closes #450.
Diffstat:
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/doc/fugitive.txt b/doc/fugitive.txt
@@ -81,6 +81,15 @@ that are part of Git repositories).
*fugitive-:Gpull*
:Gpull [args] Like |:Gmerge|, but for git-pull.
+ *fugitive-:Gpush*
+:Gpush [args] Invoke git-push, load the results into the quickfix
+ list, and invoke |:cwindow| to reveal any errors.
+ |:Dispatch| is used if available for asynchronous
+ invocation.
+
+ *fugitive-:Gfetch*
+:Gfetch [args] Like |:Gpush|, but for git-fetch.
+
*fugitive-:Ggrep*
:Ggrep [args] |:grep| with git-grep as 'grepprg'.
diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
@@ -1531,6 +1531,35 @@ augroup fugitive_commit
autocmd VimLeavePre,BufDelete COMMIT_EDITMSG execute s:sub(s:FinishCommit(), '^echoerr (.*)', 'echohl ErrorMsg|echo \1|echohl NONE')
augroup END
+" Section: Gpush, Gfetch
+
+call s:command("-nargs=? -bang -complete=custom,s:RemoteComplete Gpush execute s:Dispatch('<bang>', 'push '.<q-args>)")
+call s:command("-nargs=? -bang -complete=custom,s:RemoteComplete Gfetch execute s:Dispatch('<bang>', 'fetch '.<q-args>)")
+
+function! s:Dispatch(bang, args)
+ let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
+ let cwd = getcwd()
+ let [mp, efm, cc] = [&l:mp, &l:efm, get(b:, 'current_compiler', '')]
+ try
+ let b:current_compiler = 'git'
+ let &l:errorformat = s:common_efm
+ let &l:makeprg = g:fugitive_git_executable . ' ' . a:args
+ execute cd fnameescape(s:repo().tree())
+ if exists(':Make') == 2
+ noautocmd Make
+ else
+ silent noautocmd make!
+ redraw!
+ return 'call fugitive#cwindow()'
+ endif
+ return ''
+ finally
+ let [&l:mp, &l:efm, b:current_compiler] = [mp, efm, cc]
+ if empty(cc) | unlet! b:current_compiler | endif
+ execute cd fnameescape(cwd)
+ endtry
+endfunction
+
" Section: Gdiff
call s:command("-bang -bar -nargs=* -complete=customlist,s:EditComplete Gdiff :execute s:Diff('',<f-args>)")