Only use "-c name=value" when git supports it.

Closes #319.
This commit is contained in:
Andy Stewart
2016-04-20 12:16:06 +01:00
parent 75eee3e407
commit cc77f32b5b
2 changed files with 17 additions and 1 deletions

View File

@@ -11,6 +11,8 @@ let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
let s:fish = &shell =~# 'fish'
let s:c_flag = gitgutter#utility#git_supports_command_line_config_override()
let s:temp_index = tempname()
let s:temp_buffer = tempname()
@@ -88,7 +90,11 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff)
call setpos("']", op_mark_end)
endif
let cmd .= 'git -c "diff.autorefreshindex=0" diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' '
let cmd .= 'git'
if s:c_flag
let cmd .= ' -c "diff.autorefreshindex=0"'
endif
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' '
if a:realtime
let cmd .= ' -- '.blob_file.' '.buff_file

View File

@@ -181,3 +181,13 @@ function! gitgutter#utility#job_output_received(job_id, event)
unlet s:jobs[a:job_id]
endif
endfunction
function! gitgutter#utility#git_version()
return matchstr(system('git --version'), '[0-9.]\+')
endfunction
" True for git v1.7.2+.
function! gitgutter#utility#git_supports_command_line_config_override()
let [major, minor, patch; _] = split(gitgutter#utility#git_version(), '\.')
return major > 1 || (major == 1 && minor > 7) || (minor == 7 && patch > 1)
endfunction