Merge branch 'diffoptions'

Closes #49.
This commit is contained in:
Marco Hinz 2013-08-07 15:47:31 +02:00
commit 884622d5ef
2 changed files with 30 additions and 10 deletions

View File

@ -24,6 +24,8 @@ else
endif
endif
let s:diffoptions = get(g:, 'signify_diffoptions', {})
" Function: #detect {{{1
function! sy#repo#detect(path) abort
for type in get(g:, 'signify_vcs_list', [ 'git', 'hg', 'svn', 'darcs', 'bzr', 'fossil', 'cvs', 'rcs', 'accurev', 'perforce' ])
@ -39,7 +41,8 @@ endfunction
" Function: #get_diff_git {{{1
function! sy#repo#get_diff_git(path) abort
if executable('git')
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. sy#util#escape(a:path))
let diffoptions = has_key(s:diffoptions, 'git') ? s:diffoptions.git : ''
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 '. diffoptions .' -- '. sy#util#escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -78,7 +81,8 @@ endfunction
" Function: #get_diff_hg {{{1
function! sy#repo#get_diff_hg(path) abort
if executable('hg')
let diff = system('hg diff --nodates -U0 -- '. sy#util#escape(a:path))
let diffoptions = has_key(s:diffoptions, 'hg') ? s:diffoptions.hg : ''
let diff = system('hg diff --nodates -U0 '. diffoptions .' -- '. sy#util#escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -86,7 +90,8 @@ endfunction
" Function: #get_diff_svn {{{1
function! sy#repo#get_diff_svn(path) abort
if executable('svn')
let diff = system('svn diff --diff-cmd '. s:difftool .' -x -U0 -- '. sy#util#escape(a:path))
let diffoptions = has_key(s:diffoptions, 'svn') ? s:diffoptions.svn : ''
let diff = system('svn diff --diff-cmd '. s:difftool .' -x -U0 '. diffoptions .' -- '. sy#util#escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -94,7 +99,8 @@ endfunction
" Function: #get_diff_bzr {{{1
function! sy#repo#get_diff_bzr(path) abort
if executable('bzr')
let diff = system('bzr diff --using '. s:difftool .' --diff-options=-U0 -- '. sy#util#escape(a:path))
let diffoptions = has_key(s:diffoptions, 'bzr') ? s:diffoptions.bzr : ''
let diff = system('bzr diff --using '. s:difftool .' --diff-options=-U0 '. diffoptions .' -- '. sy#util#escape(a:path))
return ((v:shell_error == 0) || (v:shell_error == 1) || (v:shell_error == 2)) ? diff : ''
endif
endfunction
@ -102,7 +108,8 @@ endfunction
" Function: #get_diff_darcs {{{1
function! sy#repo#get_diff_darcs(path) abort
if executable('darcs')
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="'. s:difftool .' -U0 %1 %2" -- '. sy#util#escape(a:path))
let diffoptions = has_key(s:diffoptions, 'darcs') ? s:diffoptions.darcs : ''
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="'. s:difftool .' -U0 %1 %2" '. diffoptions .' -- '. sy#util#escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -110,7 +117,8 @@ endfunction
" Function: #get_diff_fossil {{{1
function! sy#repo#get_diff_fossil(path) abort
if executable('fossil')
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && fossil set diff-command "'. s:difftool .' -U 0" && fossil diff --unified -c 0 -- '. sy#util#escape(a:path))
let diffoptions = has_key(s:diffoptions, 'fossil') ? s:diffoptions.fossil : ''
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && fossil set diff-command "'. s:difftool .' -U 0" && fossil diff --unified -c 0 '. diffoptions .' -- '. sy#util#escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -118,7 +126,8 @@ endfunction
" Function: #get_diff_cvs {{{1
function! sy#repo#get_diff_cvs(path) abort
if executable('cvs')
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 -- '. sy#util#escape(fnamemodify(a:path, ':t')))
let diffoptions = has_key(s:diffoptions, 'cvs') ? s:diffoptions.cvs : ''
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 '. diffoptions .' -- '. sy#util#escape(fnamemodify(a:path, ':t')))
return v:shell_error ? '' : diff
endif
endfunction
@ -126,7 +135,8 @@ endfunction
" Function: #get_diff_rcs {{{1
function! sy#repo#get_diff_rcs(path) abort
if executable('rcs')
let diff = system('rcsdiff -U0 '. sy#util#escape(a:path) .' 2>/dev/null')
let diffoptions = has_key(s:diffoptions, 'rcs') ? s:diffoptions.rcs : ''
let diff = system('rcsdiff -U0 '. diffoptions .' '. sy#util#escape(a:path) .' 2>/dev/null')
return v:shell_error ? '' : diff
endif
endfunction
@ -134,7 +144,8 @@ endfunction
" Function: #get_diff_accurev {{{1
function! sy#repo#get_diff_accurev(path) abort
if executable('accurev')
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && accurev diff '. sy#util#escape(fnamemodify(a:path, ':t')) . ' -- -U0')
let diffoptions = has_key(s:diffoptions, 'accurev') ? s:diffoptions.accurev : ''
let diff = system('cd '. sy#util#escape(fnamemodify(a:path, ':h')) .' && accurev diff '. sy#util#escape(fnamemodify(a:path, ':t')) . ' -- -U0 '. diffoptions)
return (v:shell_error != 1) ? '' : diff
endif
endfunction
@ -142,7 +153,8 @@ endfunction
" Function: #get_diff_perforce {{{1
function! sy#repo#get_diff_perforce(path) abort
if executable('p4')
let diff = system('env P4DIFF=diff p4 diff -dU0 -- '. sy#util#escape(a:path))
let diffoptions = has_key(s:diffoptions, 'perforce') ? s:diffoptions.perforce : ''
let diff = system('env P4DIFF=diff p4 diff -dU0 '. diffoptions .' -- '. sy#util#escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction

View File

@ -208,6 +208,14 @@ Otherwise 'diff' will be used.
Default: Does not exist.
============-
let g:signify_diffoptions = { 'git': '-w', 'hg': '-w' }
This will pass the given additional options to the selected VCS diff command.
Default: Does not exist.
==============================================================================
4. Commands *signify-commands*