From f17f7da5246ee8d047d9078134b192790fce87fe Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 25 Aug 2020 09:05:09 +0200 Subject: [PATCH] Fix vim git blame not showing uncommitted changes --- vim/plugin/git.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vim/plugin/git.vim b/vim/plugin/git.vim index ab2df79..ab80bcc 100644 --- a/vim/plugin/git.vim +++ b/vim/plugin/git.vim @@ -186,18 +186,20 @@ function! s:git_blame(first, last) let l:revision = b:git_revision_hash let l:name = b:git_original_file else - let l:revision = "HEAD" + let l:revision = "" let l:name = expand("%") end if a:first.a:last == "" - let l:input = system('git blame '.l:revision.' --line-porcelain -- '.l:name) + let l:command = 'git blame '.l:revision.' --line-porcelain -- '.l:name else - let l:input = system('git blame '.l:revision.' --line-porcelain -L '.a:first.','.a:last.' -- '.l:name) + let l:command = 'git blame '.l:revision.' --line-porcelain -L '.a:first.','.a:last.' -- '.l:name end + let l:input = system(l:command) if v:shell_error throw v:shell_error else - let l:array = map(split(l:input, '\ze\x\{40} \d\+ \d\+'), s:split_blame_entry_ref) + let l:split = split(l:input, '\n\t[^\n]*\n') + let l:array = map(l:split, s:split_blame_entry_ref) return l:array end endfun