remove 'grep' dependency

First step towards proper Windows support.
This commit is contained in:
Marco Hinz 2013-03-26 23:41:14 +01:00
parent 866f3d945d
commit ae2f0bffdc

View File

@ -245,8 +245,8 @@ endfunction
" Functions -> s:repo_detect() {{{1
function! s:repo_detect(path) abort
if !executable('grep') || !executable('diff')
echo 'signify: I cannot work without grep and diff!'
if !executable('diff')
echo 'signify: I cannot work without diff!'
endif
for type in s:vcs_list
@ -262,7 +262,7 @@ endfunction
" Functions -> s:repo_get_diff_git {{{1
function! s:repo_get_diff_git(path) abort
if executable('git')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. shellescape(a:path) .' | grep --color=never "^@@ "')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. shellescape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -270,7 +270,7 @@ endfunction
" Functions -> s:repo_get_diff_hg {{{1
function! s:repo_get_diff_hg(path) abort
if executable('hg')
let diff = system('hg diff --nodates -U0 -- '. shellescape(a:path) .' | grep --color=never "^@@ "')
let diff = system('hg diff --nodates -U0 -- '. shellescape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -278,7 +278,7 @@ endfunction
" Functions -> s:repo_get_diff_svn {{{1
function! s:repo_get_diff_svn(path) abort
if executable('svn')
let diff = system('svn diff --diff-cmd diff -x -U0 -- '. shellescape(a:path) .' | grep --color=never "^@@ "')
let diff = system('svn diff --diff-cmd diff -x -U0 -- '. shellescape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -286,7 +286,7 @@ endfunction
" Functions -> s:repo_get_diff_bzr {{{1
function! s:repo_get_diff_bzr(path) abort
if executable('bzr')
let diff = system('bzr diff --using diff --diff-options=-U0 -- '. shellescape(a:path) .' | grep --color=never "^@@ "')
let diff = system('bzr diff --using diff --diff-options=-U0 -- '. shellescape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -294,7 +294,7 @@ endfunction
" Functions -> s:repo_get_diff_darcs {{{1
function! s:repo_get_diff_darcs(path) abort
if executable('darcs')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="diff -U0 %1 %2" -- '. shellescape(a:path) .' | grep --color=never "^@@ "')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="diff -U0 %1 %2" -- '. shellescape(a:path))
return v:shell_error ? '' : diff
endif
endfunction
@ -302,7 +302,7 @@ endfunction
" Functions -> s:repo_get_diff_cvs {{{1
function! s:repo_get_diff_cvs(path) abort
if executable('cvs')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 -- '. shellescape(fnamemodify(a:path, ':t')) .' | grep --color=never "^@@ "')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 -- '. shellescape(fnamemodify(a:path, ':t')))
return v:shell_error ? '' : diff
endif
endfunction
@ -310,7 +310,7 @@ endfunction
" Functions -> s:repo_get_diff_rcs {{{1
function! s:repo_get_diff_rcs(path) abort
if executable('rcs')
let diff = system('rcsdiff -U0 '. shellescape(a:path) .' 2>/dev/null | grep --color=never "^@@ "')
let diff = system('rcsdiff -U0 '. shellescape(a:path) .' 2>/dev/null')
return v:shell_error ? '' : diff
endif
endfunction
@ -320,6 +320,10 @@ function! s:repo_process_diff(path, diff) abort
" Determine where we have to put our signs.
for line in split(a:diff, '\n')
" Parse diff output.
if line !~ '^@@'
continue
endif
let tokens = matchlist(line, '^\v\@\@ -(\d+),?(\d*) \+(\d+),?(\d*)')
if empty(tokens)
echo 'signify: I cannot parse this line "'. line .'"'