adapt repo detect funcs to look like the vcs one

This commit is contained in:
Marco Hinz 2013-03-26 13:57:57 +01:00
parent b7ffe16d0f
commit 30c5a76ea9

View File

@ -259,16 +259,9 @@ endfunction
" Functions -> s:repo_get_diff_git {{{2 " Functions -> s:repo_get_diff_git {{{2
function! s:repo_get_diff_git(path) abort function! s:repo_get_diff_git(path) abort
if executable('git') if executable('git')
let orig_dir = fnameescape(getcwd()) let diff = system('cd '. fnameescape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. fnameescape(a:path) .' | grep --color=never "^@@ "')
execute 'cd '. fnameescape(fnamemodify(a:path, ':h')) return v:shell_error ? '' : diff
let diff = system('git diff --no-ext-diff -U0 -- '. fnameescape(a:path) .' | grep --color=never "^@@ "')
if !v:shell_error
execute 'cd '. orig_dir
return diff
endif
execute 'cd '. orig_dir
endif endif
return ''
endfunction endfunction
" Functions -> s:repo_get_diff_hg {{{2 " Functions -> s:repo_get_diff_hg {{{2
@ -298,16 +291,9 @@ endfunction
" Functions -> s:repo_get_diff_darcs {{{2 " Functions -> s:repo_get_diff_darcs {{{2
function! s:repo_get_diff_darcs(path) abort function! s:repo_get_diff_darcs(path) abort
if executable('darcs') if executable('darcs')
let orig_dir = fnameescape(getcwd()) let diff = system('cd '. fnameescape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="diff -U0 %1 %2" -- '. fnameescape(a:path) .' | grep --color=never "^@@ "')
execute 'cd '. fnameescape(fnamemodify(a:path, ':h')) return v:shell_error ? '' : diff
let diff = system('darcs diff --no-pause-for-gui --diff-command="diff -U0 %1 %2" -- '. fnameescape(a:path) .' | grep --color=never "^@@ "')
if !v:shell_error
execute 'cd '. orig_dir
return diff
endif
execute 'cd '. orig_dir
endif endif
return ''
endfunction endfunction
" Functions -> s:repo_get_diff_cvs {{{2 " Functions -> s:repo_get_diff_cvs {{{2