Handle file which does not exist in diff base

If g:gitgutter_diff_base has been set and the file being processed does
not exist in that branch/commit, ensure that every line is marked as
added - this is how git-diff behaves.

Fixes #855.
This commit is contained in:
Andy Stewart
2023-04-27 16:16:54 +01:00
parent 3475e974d6
commit 2ee95686c5
3 changed files with 37 additions and 0 deletions

View File

@@ -348,6 +348,21 @@ function Test_untracked_file_square_brackets_within_repo()
endfunction
function Test_file_unknown_in_base()
let starting_branch = system('git branch --show-current')
let starting_branch = 'main'
call system('git checkout -b some-feature')
let tmp = 'file-on-this-branch-only.tmp'
call system('echo "hi" > '.tmp.' && git add '.tmp)
execute 'edit '.tmp
let g:gitgutter_diff_base = starting_branch
GitGutter
let expected = [{'lnum': 1, 'name': 'GitGutterLineAdded', 'group': 'gitgutter', 'priority': 10}]
call s:assert_signs(expected, tmp)
let g:gitgutter_diff_base = ''
endfunction
function Test_hunk_outside_noop()
5
GitGutterStageHunk