Use git -C instead of cd

This commit is contained in:
Andy Stewart
2024-07-13 06:20:56 +01:00
parent e801371917
commit bed580ab8b
4 changed files with 23 additions and 37 deletions

View File

@@ -118,11 +118,16 @@ endfunction
" }}}
function! gitgutter#git()
" Optional argument is buffer number
function! gitgutter#git(...)
let git = g:gitgutter_git_executable
if a:0
let git .= ' -C '.gitgutter#utility#dir(a:1)
endif
if empty(g:gitgutter_git_args)
return g:gitgutter_git_executable
return git
else
return g:gitgutter_git_executable.' '.g:gitgutter_git_args
return git.' '.g:gitgutter_git_args
endif
endfunction
@@ -258,9 +263,7 @@ function! gitgutter#difforig()
if g:gitgutter_diff_relative_to ==# 'index'
let index_name = gitgutter#utility#get_diff_base(bufnr).':'.gitgutter#utility#base_path(bufnr)
let cmd = gitgutter#utility#cd_cmd(bufnr,
\ gitgutter#git().' --no-pager show '.index_name
\ )
let cmd = gitgutter#git(bufnr).' --no-pager show '.index_name
" NOTE: this uses &shell to execute cmd. Perhaps we should use instead
" gitgutter#utility's use_known_shell() / restore_shell() functions.
silent! execute "read ++edit !" cmd