Skip to content

Commit

Permalink
Wrap compound commands in parentheses.
Browse files Browse the repository at this point in the history
This fixes a problem on Windows where non-git-tracked files caused an
error in Vim instead of returning normally with a non-zero exit code.
  • Loading branch information
jaxbot authored and airblade committed Feb 20, 2014
1 parent f291db0 commit dff7bc8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions autoload/diff.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'


function! diff#run_diff(realtime, use_external_grep)
let cmd = 'git ls-files --error-unmatch ' . utility#shellescape(utility#file()) . ' && ('
" Wrap compound command in parentheses to make Windows happy.
let cmd = '(git ls-files --error-unmatch ' . utility#shellescape(utility#file()) . ' && ('

if a:realtime
let blob_name = ':' . utility#shellescape(utility#file_relative_to_repo_root())
Expand All @@ -22,7 +23,7 @@ function! diff#run_diff(realtime, use_external_grep)
let cmd .= s:grep_command . ' || true'
endif

let cmd .= ')'
let cmd .= '))'

if a:realtime
let diff = system(utility#command_in_directory_of_file(cmd), utility#buffer_contents())
Expand Down

0 comments on commit dff7bc8

Please sign in to comment.