From 5225697d9c76e54e434076d29d27cb815cb88a17 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 3 Mar 2012 10:08:00 -0500 Subject: [PATCH] Revert "Use --work-tree to fix :cd side effects in :Gcommit" This reverts commit 903ad4d70470fed5d73e1b0d61c1bbf42d19104c, which broke :Gcommit when invoked from a subdirectory of the repository. --- plugin/fugitive.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 5002495..15bcc5c 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -773,10 +773,13 @@ endfunction call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit()") function! s:Commit(args) abort + let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' + let dir = getcwd() let msgfile = s:repo().dir('COMMIT_EDITMSG') let outfile = tempname() let errorfile = tempname() try + execute cd.'`=s:repo().tree()`' if &shell =~# 'cmd' let command = '' let old_editor = $GIT_EDITOR @@ -784,7 +787,7 @@ function! s:Commit(args) abort else let command = 'env GIT_EDITOR=false ' endif - let command .= s:sub(s:repo().git_command('commit'),'--git-dir','--work-tree='.s:shellesc(s:repo().tree()).' --git-dir').' '.a:args + let command .= s:repo().git_command('commit').' '.a:args if &shell =~# 'csh' silent execute '!('.command.' > '.outfile.') >& '.errorfile elseif a:args =~# '\%(^\| \)--interactive\>' @@ -840,6 +843,7 @@ function! s:Commit(args) abort endif call delete(outfile) call delete(errorfile) + execute cd.'`=dir`' call fugitive#reload_status() endtry endfunction