diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index b92f2f9..c9b5779 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -779,22 +779,26 @@ function! s:Commit(args) abort let outfile = tempname() let errorfile = tempname() try - execute cd.'`=s:repo().tree()`' - if &shell =~# 'cmd' - let command = '' - let old_editor = $GIT_EDITOR - let $GIT_EDITOR = 'false' - else - let command = 'env GIT_EDITOR=false ' - endif - let command .= s:repo().git_command('commit').' '.a:args - if &shell =~# 'csh' - silent execute '!('.command.' > '.outfile.') >& '.errorfile - elseif a:args =~# '\%(^\| \)--interactive\>' - execute '!'.command.' 2> '.errorfile - else - silent execute '!'.command.' > '.outfile.' 2> '.errorfile - endif + try + execute cd.s:fnameescape(s:repo().tree()) + if &shell =~# 'cmd' + let command = '' + let old_editor = $GIT_EDITOR + let $GIT_EDITOR = 'false' + else + let command = 'env GIT_EDITOR=false ' + endif + let command .= s:repo().git_command('commit').' '.a:args + if &shell =~# 'csh' + silent execute '!('.command.' > '.outfile.') >& '.errorfile + elseif a:args =~# '\%(^\| \)--interactive\>' + execute '!'.command.' 2> '.errorfile + else + silent execute '!'.command.' > '.outfile.' 2> '.errorfile + endif + finally + execute cd.'`=dir`' + endtry if !has('gui_running') redraw! endif @@ -827,7 +831,7 @@ function! s:Commit(args) abort execute 'keepalt split '.s:fnameescape(msgfile) endif let b:fugitive_commit_arguments = args - setlocal bufhidden=delete filetype=gitcommit + setlocal bufhidden=wipe filetype=gitcommit return '1' elseif error ==# '!' return s:Status() @@ -843,7 +847,6 @@ function! s:Commit(args) abort endif call delete(outfile) call delete(errorfile) - execute cd.'`=dir`' call fugitive#reload_status() endtry endfunction