From ee2b0ecdb80ec3e8d544e3f2f895275e0f76e292 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 30 Jun 2014 14:30:44 -0400 Subject: [PATCH] Provide :Gpush and :Gfetch Closes #450. --- doc/fugitive.txt | 9 +++++++++ plugin/fugitive.vim | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 322ed5f..0d186bf 100644 --- 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 index 31c385b..7232066 100644 --- 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('', 'push '.)") +call s:command("-nargs=? -bang -complete=custom,s:RemoteComplete Gfetch execute s:Dispatch('', 'fetch '.)") + +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('',)")