simplify git detection
This commit is contained in:
parent
8cf6c61795
commit
aefd88057e
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user