simplify git detection

This commit is contained in:
Marco Hinz 2013-03-11 18:58:57 +01:00
parent 8cf6c61795
commit aefd88057e

View File

@ -226,16 +226,11 @@ function! s:diff_get(path) abort
if executable('git')
let orig_dir = getcwd()
let wt = fnamemodify(a:path, ':h')
exe 'cd '. wt
let gd = system('git rev-parse --git-dir')[:-2] " remove newline
exe 'cd '. fnamemodify(a:path, ':h')
let diff = system('git diff --no-ext-diff -U0 -- '. a:path .' | grep "^@@ "')
if !v:shell_error
let wt = fnamemodify(gd, ':h')
let diff = system('git --work-tree '. wt .' --git-dir '. gd .' diff --no-ext-diff -U0 -- '. a:path .' | grep "^@@ "')
if !v:shell_error
exe 'cd '. orig_dir
return diff
endif
exe 'cd '. orig_dir
return diff
endif
exe 'cd '. orig_dir
endif