Skip to content

Commit

Permalink
Make grep optional instead of required.
Browse files Browse the repository at this point in the history
When grep is available we use it for efficiency.  When it's unavailable,
we filter in Vimscript.
  • Loading branch information
airblade committed Apr 5, 2013
1 parent 93288af commit 5bc25a8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugin/gitgutter.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if exists('g:loaded_gitgutter') || !executable('git') || !executable('grep') || !has('signs') || &cp
if exists('g:loaded_gitgutter') || !executable('git') || !has('signs') || &cp
finish
endif
let g:loaded_gitgutter = 1
Expand Down Expand Up @@ -47,6 +47,8 @@ function! s:init()
let s:other_signs = []
let s:dummy_sign_id = 153

let s:grep_available = executable('grep')

let g:gitgutter_initialised = 1
endif
endfunction
Expand Down Expand Up @@ -189,8 +191,10 @@ endfunction
" Diff processing {{{

function! s:run_diff()
let cmd = 'git diff --no-ext-diff --no-color -U0 ' . g:gitgutter_diff_args . ' ' .
\ shellescape(s:file()) . ' | grep -e "^@@ "'
let cmd = 'git diff --no-ext-diff --no-color -U0 ' . g:gitgutter_diff_args . ' ' . shellescape(s:file())
if s:grep_available
let cmd .= ' | grep -e "^@@ "'
endif
let diff = system(s:command_in_directory_of_file(cmd))
return diff
endfunction
Expand Down

0 comments on commit 5bc25a8

Please sign in to comment.