[PATCH] be more robust wrt the git-dir.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
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\<esc>1GddO\<esc>"
+ 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\<esc>1GddO\<esc>"
+ exe 'cd '.wd
setlocal nomodifiable
+ noremap <buffer> q :bw<cr>
if a:auto
redraw!
wincmd p
--
1.4.2.3