mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 19:43:47 -05:00
Allow configuration of git executable.
This commit is contained in:
@@ -181,7 +181,7 @@ function! gitgutter#stage_hunk() abort
|
|||||||
call gitgutter#utility#warn('cursor is not in a hunk')
|
call gitgutter#utility#warn('cursor is not in a hunk')
|
||||||
else
|
else
|
||||||
let diff_for_hunk = gitgutter#diff#generate_diff_for_hunk(diff, 'stage')
|
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
|
" refresh gitgutter's view of buffer
|
||||||
silent execute "GitGutter"
|
silent execute "GitGutter"
|
||||||
@@ -203,7 +203,7 @@ function! gitgutter#undo_hunk() abort
|
|||||||
call gitgutter#utility#warn('cursor is not in a hunk')
|
call gitgutter#utility#warn('cursor is not in a hunk')
|
||||||
else
|
else
|
||||||
let diff_for_hunk = gitgutter#diff#generate_diff_for_hunk(diff, 'undo')
|
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
|
" reload file
|
||||||
silent edit
|
silent edit
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ function! gitgutter#debug#vim_version()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#debug#git_version()
|
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$', '', '') )
|
call gitgutter#debug#output( substitute(v, '\n$', '', '') )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff) abort
|
|||||||
let bufnr = gitgutter#utility#bufnr()
|
let bufnr = gitgutter#utility#bufnr()
|
||||||
let tracked = getbufvar(bufnr, 'gitgutter_tracked') " i.e. tracked by git
|
let tracked = getbufvar(bufnr, 'gitgutter_tracked') " i.e. tracked by git
|
||||||
if !tracked
|
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
|
endif
|
||||||
|
|
||||||
if a:realtime
|
if a:realtime
|
||||||
@@ -70,7 +70,7 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff) abort
|
|||||||
let blob_file .= '.'.extension
|
let blob_file .= '.'.extension
|
||||||
let buff_file .= '.'.extension
|
let buff_file .= '.'.extension
|
||||||
endif
|
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
|
" Writing the whole buffer resets the '[ and '] marks and also the
|
||||||
" 'modified' flag (if &cpoptions includes '+'). These are unwanted
|
" '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)
|
call setpos("']", op_mark_end)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let cmd .= 'git'
|
let cmd .= g:gitgutter_git_executable
|
||||||
if s:c_flag
|
if s:c_flag
|
||||||
let cmd .= ' -c "diff.autorefreshindex=0"'
|
let cmd .= ' -c "diff.autorefreshindex=0"'
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ endfunction
|
|||||||
function! gitgutter#utility#file_relative_to_repo_root() abort
|
function! gitgutter#utility#file_relative_to_repo_root() abort
|
||||||
let file_path_relative_to_repo_root = getbufvar(s:bufnr, 'gitgutter_repo_relative_path')
|
let file_path_relative_to_repo_root = getbufvar(s:bufnr, 'gitgutter_repo_relative_path')
|
||||||
if empty(file_path_relative_to_repo_root)
|
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 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()
|
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)
|
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
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#utility#git_version() abort
|
function! gitgutter#utility#git_version() abort
|
||||||
return matchstr(system('git --version'), '[0-9.]\+')
|
return matchstr(system(g:gitgutter_git_executable.' --version'), '[0-9.]\+')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" True for git v1.7.2+.
|
" True for git v1.7.2+.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
if exists('g:loaded_gitgutter') || !executable('git') || !has('signs') || &cp
|
if exists('g:loaded_gitgutter') || !has('signs') || &cp
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_gitgutter = 1
|
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_avoid_cmd_prompt_on_windows', 1)
|
||||||
call s:set('g:gitgutter_async', 1)
|
call s:set('g:gitgutter_async', 1)
|
||||||
call s:set('g:gitgutter_log', 0)
|
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_sign_column_highlight()
|
||||||
call gitgutter#highlight#define_highlights()
|
call gitgutter#highlight#define_highlights()
|
||||||
|
|||||||
Reference in New Issue
Block a user