From: Pierre Habouzit Date: Wed, 18 Oct 2006 00:47:26 GMT Subject: [PATCH] be more robust wrt the git-dir. Message-ID: <1161132446703-git-send-email-madcoder@debian.org> In-Reply-To: <11611324463754-git-send-email-madcoder@debian.org> Signed-off-by: Pierre Habouzit --- contrib/vim/ftplugin/gitcommit.vim | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/vim/ftplugin/gitcommit.vim b/contrib/vim/ftplugin/gitcommit.vim index a9cb946..e958fb1 100644 --- a/contrib/vim/ftplugin/gitcommit.vim +++ b/contrib/vim/ftplugin/gitcommit.vim @@ -52,9 +52,17 @@ function! Git_diff_windows(vertsplit, au rightbelow new endif silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile - exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . "\n1Gdd" - exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . " \| git apply --stat\no\1GddO\" + let gitDir = system('git rev-parse --git-dir 2>/dev/null') + let gitDir = substitute(gitDir, '.git\n', '', '') + let wd = getcwd() + if gitDir != '' + exe 'cd '.gitDir + endif + exe 'normal :r!LANG=C git diff HEAD -- ' . list_of_files . "\n1Gdd" + exe 'normal :r!LANG=C git diff HEAD -- ' . list_of_files . " \| git apply --stat\no\1GddO\" + exe 'cd '.wd setlocal nomodifiable + noremap q :bw if a:auto redraw! wincmd p -- 1.4.2.3