mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Remove "file unknown in base" check
Instead of checking whether this file exists in `diff_base` and
returning early, we let `git show` fail, which still creates an empty
`from_file` for the subsequent `git diff` to use.
This mostly reverts 2ee95686c5, but we
keep the test case.
This commit is contained in:
@@ -46,8 +46,6 @@ function! gitgutter#process_buffer(bufnr, force) abort
|
|||||||
call gitgutter#debug#log('Not tracked: '.gitgutter#utility#file(a:bufnr))
|
call gitgutter#debug#log('Not tracked: '.gitgutter#utility#file(a:bufnr))
|
||||||
catch /gitgutter assume unchanged/
|
catch /gitgutter assume unchanged/
|
||||||
call gitgutter#debug#log('Assume unchanged: '.gitgutter#utility#file(a:bufnr))
|
call gitgutter#debug#log('Assume unchanged: '.gitgutter#utility#file(a:bufnr))
|
||||||
catch /gitgutter file unknown in base/
|
|
||||||
let diff = gitgutter#diff#hunk_header_showing_every_line_added(a:bufnr)
|
|
||||||
catch /gitgutter diff failed/
|
catch /gitgutter diff failed/
|
||||||
call gitgutter#debug#log('Diff failed: '.gitgutter#utility#file(a:bufnr))
|
call gitgutter#debug#log('Diff failed: '.gitgutter#utility#file(a:bufnr))
|
||||||
call gitgutter#hunk#reset(a:bufnr)
|
call gitgutter#hunk#reset(a:bufnr)
|
||||||
|
|||||||
@@ -81,20 +81,6 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
|||||||
throw 'gitgutter assume unchanged'
|
throw 'gitgutter assume unchanged'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If we are diffing against a specific branch/commit, handle the case
|
|
||||||
" where a file exists on the current branch but not in/at the diff base.
|
|
||||||
" We have to handle it here because the approach below (using git-show)
|
|
||||||
" doesn't work for this case.
|
|
||||||
if !empty(g:gitgutter_diff_base)
|
|
||||||
let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#repo_path(a:bufnr, 1)
|
|
||||||
let cmd = gitgutter#git().' --no-pager show '.index_name
|
|
||||||
let cmd = gitgutter#utility#cd_cmd(a:bufnr, cmd)
|
|
||||||
let [_, error_code] = gitgutter#utility#system(cmd)
|
|
||||||
if error_code
|
|
||||||
throw 'gitgutter file unknown in base'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Wrap compound commands in parentheses to make Windows happy.
|
" Wrap compound commands in parentheses to make Windows happy.
|
||||||
" bash doesn't mind the parentheses.
|
" bash doesn't mind the parentheses.
|
||||||
let cmd = '('
|
let cmd = '('
|
||||||
@@ -138,7 +124,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
|||||||
|
|
||||||
" Write file from index to temporary file.
|
" Write file from index to temporary file.
|
||||||
let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.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 .= gitgutter#git().' --no-pager show --textconv '.index_name.' > '.from_file.' && '
|
let cmd .= gitgutter#git().' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && ('
|
||||||
|
|
||||||
elseif a:from ==# 'working_tree'
|
elseif a:from ==# 'working_tree'
|
||||||
let from_file = gitgutter#utility#repo_path(a:bufnr, 1)
|
let from_file = gitgutter#utility#repo_path(a:bufnr, 1)
|
||||||
@@ -390,12 +376,6 @@ function! gitgutter#diff#hunk_diff(bufnr, full_diff, ...)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! gitgutter#diff#hunk_header_showing_every_line_added(bufnr)
|
|
||||||
let buf_line_count = getbufinfo(a:bufnr)[0].linecount
|
|
||||||
return '@@ -0,0 +1,'.buf_line_count.' @@'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! s:write_buffer(bufnr, file)
|
function! s:write_buffer(bufnr, file)
|
||||||
let bufcontents = getbufline(a:bufnr, 1, '$')
|
let bufcontents = getbufline(a:bufnr, 1, '$')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user