commit 2e4c9236d6a23784ef6980000bee92d8ec74e6d2 (tree)
parent 3933bfdc57396f6f24f64f5ad0110d8694f11459
Author: Tim Pope <code@tpope.net>
Date: Sun, 27 Feb 2011 13:58:05 -0500
Implement :Gwq
Diffstat:
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/doc/fugitive.txt b/doc/fugitive.txt
@@ -118,6 +118,13 @@ that are part of Git repositories).
:0:foo.txt or even :0 to write to just that stage in
the index.
+ *fugitive-:Gwq*
+:Gwq [path] Like |:Gwrite| followed by |:quit| if the write
+ succeeded.
+
+:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
+ succeeded.
+
*fugitive-:Gdiff*
:Gdiff [revision] Perform a |vimdiff| against the current file in the
given revision. With no argument, the version in the
diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
@@ -903,6 +903,8 @@ call s:command("-bar -bang -nargs=? -count -complete=customlist,s:EditComplete G
" Gwrite, Gwq {{{1
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwrite :execute s:Write(<bang>0,<f-args>)")
+call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gw :execute s:Write(<bang>0,<f-args>)")
+call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwq :execute s:Wq(<bang>0,<f-args>)")
function! s:Write(force,...) abort
if exists('b:fugitive_commit_arguments')
@@ -1022,6 +1024,19 @@ function! s:Write(force,...) abort
return 'checktime'
endfunction
+function! s:Wq(force,...) abort
+ let bang = a:force ? '!' : ''
+ if exists('b:fugitive_commit_arguments')
+ return 'wq'.bang
+ endif
+ let result = call(s:function('s:Write'),[a:force]+a:000)
+ if result =~# '^\%(write\|wq\|echoerr\)'
+ return s:sub(result,'^write','wq')
+ else
+ return result.'|quit'.bang
+ endif
+endfunction
+
" }}}1
" Gdiff {{{1