From 0a7ffc5d671b1d9bc6d57b08c72cd47597b61288 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 13 Aug 2019 16:27:21 -0400 Subject: [PATCH] Use descendant when jumping to patch for :Gblame --reverse References https://github.com/tpope/vim-fugitive/issues/1305 --- autoload/fugitive.vim | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 9f1f83b..2f5b117 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -4591,14 +4591,17 @@ endfunction function! s:BlameCommitFileLnum(...) abort let line = a:0 ? a:1 : getline('.') + let state = a:0 ? a:2 : s:TempState() let commit = matchstr(line, '^\^\=\zs\x\+') if commit =~# '^0\+$' let commit = '' + elseif line !~# '^\^' && has_key(state, 'blame_reverse_end') + let commit = get(s:LinesError('log', '--pretty=format:%H', '-1', '--ancestry-path', '--reverse', commit . '..' . state.blame_reverse_end)[0], 0, commit) endif let lnum = +matchstr(line, ' \zs\d\+\ze \%((\| *\d\+)\)') let path = matchstr(line, '^\^\=\x* \+\%(\d\+ \+\d\+ \+\)\=\zs.\{-\}\ze\s\+\%(\%( \d\+ \)\@ 0 let edit = s:Mods(a:mods) . get(['edit', 'split', 'pedit', 'vsplit', 'tabedit'], a:count - (a:line1 ? a:line1 : 1), 'split') - return s:BlameCommit(edit, get(readfile(temp), 0, ''), file) + return s:BlameCommit(edit, get(readfile(temp), 0, ''), temp_state) else let temp = s:Resolve(temp) - let s:temp_files[s:cpath(temp)] = {'dir': s:Dir(), 'filetype': (raw ? '' : 'fugitiveblame'), 'blame_flags': flags, 'blame_file': file, 'modifiable': 0} + let s:temp_files[s:cpath(temp)] = temp_state if len(ranges + commits + files) || raw if a:count != 0 exe 'silent keepalt split ' . s:fnameescape(temp) @@ -4777,7 +4784,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort endif endfor let bufnr = bufnr('') - let s:temp_files[s:cpath(temp)].bufnr = bufnr + let temp_state.bufnr = bufnr let restore = 'call setwinvar(bufwinnr('.bufnr.'),"&scrollbind",0)' if exists('+cursorbind') let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&cursorbind",0)'