From 94a5d6fe2f4f1abdabd97ffb243f8333bb20aa52 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 30 Jun 2014 14:02:53 -0400 Subject: [PATCH] Fix :Gcommit when closing message lands in different project --- plugin/fugitive.vim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 031a04a..31c385b 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -964,15 +964,16 @@ endfunction call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit()") -function! s:Commit(args) abort +function! s:Commit(args, ...) abort + let repo = a:0 ? a:1 : s:repo() let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' let dir = getcwd() - let msgfile = s:repo().dir('COMMIT_EDITMSG') + let msgfile = repo.dir('COMMIT_EDITMSG') let outfile = tempname() let errorfile = tempname() try try - execute cd.s:fnameescape(s:repo().tree()) + execute cd.s:fnameescape(repo.tree()) if s:winshell() let command = '' let old_editor = $GIT_EDITOR @@ -980,7 +981,7 @@ function! s:Commit(args) abort else let command = 'env GIT_EDITOR=false ' endif - let command .= s:repo().git_command('commit').' '.a:args + let command .= repo.git_command('commit').' '.a:args if &shell =~# 'csh' noautocmd silent execute '!('.command.' > '.outfile.') >& '.errorfile elseif a:args =~# '\%(^\| \)-\%(-interactive\|p\|-patch\)\>' @@ -1058,7 +1059,7 @@ function! s:FinishCommit() abort let args = getbufvar(+expand(''),'fugitive_commit_arguments') if !empty(args) call setbufvar(+expand(''),'fugitive_commit_arguments','') - return s:Commit(args) + return s:Commit(args, s:repo(getbufvar(+expand(''),'git_dir'))) endif return '' endfunction