[PATCH] be more robust wrt the git-dir.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jeff King <peff@...>
Cc: <git@...>, Pierre Habouzit <madcoder@...>
Date: Tuesday, October 17, 2006 - 8:47 pm

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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
contrib/vim patches, replace the previous set, Pierre Habouzit, (Tue Oct 17, 8:39 pm)
Make the ftplugin right wrt gitdir, Pierre Habouzit, (Tue Oct 17, 8:47 pm)
Re: Make the ftplugin right wrt gitdir, Jeff King, (Wed Oct 18, 3:02 am)
Re: Make the ftplugin right wrt gitdir, Pierre Habouzit, (Wed Oct 18, 4:10 am)
Re: Make the ftplugin right wrt gitdir, Jeff King, (Wed Oct 18, 5:02 am)
Re: Make the ftplugin right wrt gitdir, Pierre Habouzit, (Wed Oct 18, 5:07 am)
Re: Make the ftplugin right wrt gitdir, Jeff King, (Wed Oct 18, 5:46 am)
[PATCH] be more robust wrt the git-dir., Pierre Habouzit, (Tue Oct 17, 8:47 pm)
contrib/vim patches, replace the previous set, Pierre Habouzit, (Tue Oct 17, 8:38 pm)