Only diff against parent commit in Fugitive revision buffers

Fixes #695.
This commit is contained in:
Andy Stewart
2020-04-18 17:13:15 +01:00
parent 5f6048da13
commit 2b62481d38
3 changed files with 4 additions and 5 deletions

View File

@@ -33,8 +33,6 @@ function! gitgutter#process_buffer(bufnr, force) abort
return return
endif endif
call gitgutter#utility#set_diff_base_if_fugitive(a:bufnr)
if a:force || s:has_fresh_changes(a:bufnr) if a:force || s:has_fresh_changes(a:bufnr)
let diff = 'NOT SET' let diff = 'NOT SET'

View File

@@ -120,7 +120,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
endif endif
" Write file from index to temporary file. " Write file from index to temporary file.
let index_name = g:gitgutter_diff_base.':'.gitgutter#utility#repo_path(a:bufnr, 1) let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#repo_path(a:bufnr, 1)
let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager show '.index_name.' > '.from_file.' && ' let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager show '.index_name.' > '.from_file.' && '
elseif a:from ==# 'working_tree' elseif a:from ==# 'working_tree'

View File

@@ -184,12 +184,13 @@ function! s:restore_shell() abort
endif endif
endfunction endfunction
function! gitgutter#utility#set_diff_base_if_fugitive(bufnr) function! gitgutter#utility#get_diff_base(bufnr)
let p = resolve(expand('#'.a:bufnr.':p')) let p = resolve(expand('#'.a:bufnr.':p'))
let ml = matchlist(p, '\v^fugitive:/.*/(\x{40,})/') let ml = matchlist(p, '\v^fugitive:/.*/(\x{40,})/')
if !empty(ml) && !empty(ml[1]) if !empty(ml) && !empty(ml[1])
let g:gitgutter_diff_base = ml[1].'^' return ml[1].'^'
endif endif
return g:gitgutter_diff_base
endfunction endfunction
function! s:abs_path(bufnr, shellesc) function! s:abs_path(bufnr, shellesc)