Allow configuration of git executable.

This commit is contained in:
Andy Stewart
2016-05-16 13:47:14 +01:00
parent 9db8f638db
commit f5a5234f22
5 changed files with 14 additions and 9 deletions

View File

@@ -181,7 +181,7 @@ function! gitgutter#stage_hunk() abort
call gitgutter#utility#warn('cursor is not in a hunk')
else
let diff_for_hunk = gitgutter#diff#generate_diff_for_hunk(diff, 'stage')
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file('git apply --cached --unidiff-zero - '), diff_for_hunk)
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' apply --cached --unidiff-zero - '), diff_for_hunk)
" refresh gitgutter's view of buffer
silent execute "GitGutter"
@@ -203,7 +203,7 @@ function! gitgutter#undo_hunk() abort
call gitgutter#utility#warn('cursor is not in a hunk')
else
let diff_for_hunk = gitgutter#diff#generate_diff_for_hunk(diff, 'undo')
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file('git apply --reverse --unidiff-zero - '), diff_for_hunk)
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' apply --reverse --unidiff-zero - '), diff_for_hunk)
" reload file
silent edit

View File

@@ -47,7 +47,7 @@ function! gitgutter#debug#vim_version()
endfunction
function! gitgutter#debug#git_version()
let v = system('git --version')
let v = system(g:gitgutter_git_executable.' --version')
call gitgutter#debug#output( substitute(v, '\n$', '', '') )
endfunction

View File

@@ -58,7 +58,7 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff) abort
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 .= g:gitgutter_git_executable.' ls-files --error-unmatch '.gitgutter#utility#shellescape(gitgutter#utility#filename()).' && ('
endif
if a:realtime
@@ -70,7 +70,7 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff) abort
let blob_file .= '.'.extension
let buff_file .= '.'.extension
endif
let cmd .= 'git show '.blob_name.' > '.blob_file.' && '
let cmd .= g:gitgutter_git_executable.' show '.blob_name.' > '.blob_file.' && '
" Writing the whole buffer resets the '[ and '] marks and also the
" 'modified' flag (if &cpoptions includes '+'). These are unwanted
@@ -86,7 +86,7 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff) abort
call setpos("']", op_mark_end)
endif
let cmd .= 'git'
let cmd .= g:gitgutter_git_executable
if s:c_flag
let cmd .= ' -c "diff.autorefreshindex=0"'
endif

View File

@@ -138,7 +138,7 @@ endfunction
function! gitgutter#utility#file_relative_to_repo_root() abort
let file_path_relative_to_repo_root = getbufvar(s:bufnr, 'gitgutter_repo_relative_path')
if empty(file_path_relative_to_repo_root)
let dir_path_relative_to_repo_root = gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file('git rev-parse --show-prefix'))
let dir_path_relative_to_repo_root = gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' rev-parse --show-prefix'))
let dir_path_relative_to_repo_root = gitgutter#utility#strip_trailing_new_line(dir_path_relative_to_repo_root)
let file_path_relative_to_repo_root = dir_path_relative_to_repo_root . gitgutter#utility#filename()
call setbufvar(s:bufnr, 'gitgutter_repo_relative_path', file_path_relative_to_repo_root)
@@ -169,7 +169,7 @@ function! gitgutter#utility#strip_trailing_new_line(line) abort
endfunction
function! gitgutter#utility#git_version() abort
return matchstr(system('git --version'), '[0-9.]\+')
return matchstr(system(g:gitgutter_git_executable.' --version'), '[0-9.]\+')
endfunction
" True for git v1.7.2+.

View File

@@ -1,6 +1,6 @@
scriptencoding utf-8
if exists('g:loaded_gitgutter') || !executable('git') || !has('signs') || &cp
if exists('g:loaded_gitgutter') || !has('signs') || &cp
finish
endif
let g:loaded_gitgutter = 1
@@ -51,6 +51,11 @@ call s:set('g:gitgutter_map_keys', 1)
call s:set('g:gitgutter_avoid_cmd_prompt_on_windows', 1)
call s:set('g:gitgutter_async', 1)
call s:set('g:gitgutter_log', 0)
call s:set('g:gitgutter_git_executable', 'git')
if !executable('git')
call gitgutter#utility#warn('cannot find git. Please set g:gitgutter_git_executable.')
endif
call gitgutter#highlight#define_sign_column_highlight()
call gitgutter#highlight#define_highlights()