mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-10 04:23:46 -05:00
Minor refactor.
This commit is contained in:
@@ -9,23 +9,18 @@ if s:grep_available
|
||||
endif
|
||||
let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
|
||||
|
||||
let s:fish = &shell =~# 'fish'
|
||||
|
||||
function! gitgutter#diff#run_diff(realtime, use_external_grep)
|
||||
" Detect whether user uses fish shell
|
||||
let l:fish = &shell =~# 'fish'
|
||||
|
||||
if !l:fish
|
||||
" Wrap compound commands in parentheses to make Windows happy.
|
||||
let cmd = '('
|
||||
else
|
||||
let cmd = ''
|
||||
end
|
||||
" Wrap compound commands in parentheses to make Windows happy.
|
||||
" bash doesn't mind the parentheses; fish doesn't want them.
|
||||
let cmd = s:fish ? '' : '('
|
||||
|
||||
let bufnr = gitgutter#utility#bufnr()
|
||||
let tracked = getbufvar(bufnr, 'gitgutter_tracked') " i.e. tracked by git
|
||||
if !tracked
|
||||
let cmd .= 'git ls-files --error-unmatch '.gitgutter#utility#shellescape(gitgutter#utility#filename())
|
||||
let cmd .= l:fish ? '; and ' : ' && ('
|
||||
let cmd .= s:fish ? '; and ' : ' && ('
|
||||
endif
|
||||
|
||||
if a:realtime
|
||||
@@ -38,7 +33,7 @@ function! gitgutter#diff#run_diff(realtime, use_external_grep)
|
||||
let buff_file .= '.'.extension
|
||||
endif
|
||||
let cmd .= 'git show '.blob_name.' > '.blob_file
|
||||
let cmd .= l:fish ? '; and ' : ' && '
|
||||
let cmd .= s:fish ? '; and ' : ' && '
|
||||
|
||||
" Writing the whole buffer resets the '[ and '] marks and also the
|
||||
" 'modified' flag (if &cpoptions includes '+'). These are unwanted
|
||||
@@ -70,10 +65,11 @@ function! gitgutter#diff#run_diff(realtime, use_external_grep)
|
||||
" differences are found. However we want to treat non-matches and
|
||||
" differences as non-erroneous behaviour; so we OR the command with one
|
||||
" which always exits with success (0).
|
||||
let cmd.= l:fish ? '; or exit 0' : ' || exit 0'
|
||||
let cmd .= s:fish ? '; or ' : ' || '
|
||||
let cmd .= 'exit 0'
|
||||
endif
|
||||
|
||||
if !l:fish
|
||||
if !s:fish
|
||||
let cmd .= ')'
|
||||
|
||||
if !tracked
|
||||
|
||||
Reference in New Issue
Block a user