diff --git a/README.markdown b/README.markdown index 4509a49..a5f91f6 100644 --- a/README.markdown +++ b/README.markdown @@ -20,7 +20,7 @@ changed, or `o` to open it in a split. When you're done, use `:Gedit` in the historic buffer to go back to the work tree version. `:Gmove` does a `git mv` on a file and simultaneously renames the -buffer. `:Gremove` does a `git rm` on a file and simultaneously deletes +buffer. `:Gdelete` does a `git rm` on a file and simultaneously deletes the buffer. Use `:Ggrep` to search the work tree (or any arbitrary commit) with diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 84d741d..b591803 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -198,12 +198,15 @@ that are part of Git repositories). directory except when started with a /, in which case it is relative to the work tree. Add a ! to pass -f. - *fugitive-:Gremove* -:Gremove Wrapper around git-rm that deletes the buffer + *fugitive-:Gdelete* +:Gdelete Wrapper around git-rm that deletes the buffer afterward. When invoked in an index file, --cached is passed. Add a ! to pass -f and forcefully discard the buffer. + *fugitive-:Gremove* +:Gremove Like :Gdelete, but keep the (now empty) buffer around. + *fugitive-:Gblame* :Gblame [flags] Run git-blame on the file and open the results in a scroll bound vertical split. You can give any of diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index a395a5d..fba368d 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1924,7 +1924,7 @@ function! s:MoveComplete(A,L,P) abort endif endfunction -function! s:Remove(force) abort +function! s:Remove(after, force) abort if s:buffer().commit() ==# '' let cmd = ['rm'] elseif s:buffer().commit() ==# '0' @@ -1942,7 +1942,7 @@ function! s:Remove(force) abort return 'echoerr '.string(v:errmsg) else call fugitive#reload_status() - return 'edit'.(a:force ? '!' : '') + return a:after . (a:force ? '!' : '') endif endfunction @@ -1950,7 +1950,8 @@ augroup fugitive_remove autocmd! autocmd User Fugitive if s:buffer().commit() =~# '^0\=$' | \ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,s:MoveComplete Gmove :execute s:Move(0,)" | - \ exe "command! -buffer -bar -bang Gremove :execute s:Remove(0)" | + \ exe "command! -buffer -bar -bang Gremove :execute s:Remove('edit',0)" | + \ exe "command! -buffer -bar -bang Gdelete :execute s:Remove('bdelete',0)" | \ endif augroup END