Jump to file not diff for boundary commit in :Gblame

This commit is contained in:
Tim Pope 2019-08-13 20:31:16 -04:00
parent 11691b38bb
commit c21736dde7
2 changed files with 22 additions and 9 deletions

View File

@ -4596,7 +4596,7 @@ function! s:BlameCommitFileLnum(...) abort
if commit =~# '^0\+$' if commit =~# '^0\+$'
let commit = '' let commit = ''
elseif line !~# '^\^' && has_key(state, 'blame_reverse_end') elseif line !~# '^\^' && has_key(state, 'blame_reverse_end')
let commit = get(s:LinesError('rev-list', '--ancestry-path', '--reverse', commit . '..' . state.blame_reverse_end)[0], 0, commit) let commit = get(s:LinesError('rev-list', '--ancestry-path', '--reverse', commit . '..' . state.blame_reverse_end)[0], 0, '')
endif endif
let lnum = +matchstr(line, ' \zs\d\+\ze \%((\| *\d\+)\)') let lnum = +matchstr(line, ' \zs\d\+\ze \%((\| *\d\+)\)')
let path = matchstr(line, '^\^\=\x* \+\%(\d\+ \+\d\+ \+\)\=\zs.\{-\}\ze\s\+\%(\%( \d\+ \)\@<!([^()]*\w \d\+)\|\d\+ \)') let path = matchstr(line, '^\^\=\x* \+\%(\d\+ \+\d\+ \+\)\=\zs.\{-\}\ze\s\+\%(\%( \d\+ \)\@<!([^()]*\w \d\+)\|\d\+ \)')
@ -4833,12 +4833,23 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort
endfunction endfunction
function! s:BlameCommit(cmd, ...) abort function! s:BlameCommit(cmd, ...) abort
let [commit, path, lnum] = call('s:BlameCommitFileLnum', a:000) let line = a:0 ? a:1 : getline('.')
let state = a:0 ? a:2 : s:TempState()
let sigil = has_key(state, 'blame_reverse_end') ? '-' : '+'
let mods = (s:BlameBufnr() < 0 ? '' : &splitbelow ? "botright " : "topleft ")
let [commit, path, lnum] = s:BlameCommitFileLnum(line, state)
if empty(commit) && len(path) && has_key(state, 'blame_reverse_end')
let path = (len(state.blame_reverse_end) ? state.blame_reverse_end . ':' : ':(top)') . path
return s:Open(mods . a:cmd, 0, '', '+' . lnum . ' ' . s:fnameescape(path), ['+' . lnum, path])
endif
if commit =~# '^0*$' if commit =~# '^0*$'
return 'echoerr ' . string('fugitive: no commit') return 'echoerr ' . string('fugitive: no commit')
endif endif
let sigil = has_key(a:0 ? a:2 : s:TempState(), 'blame_reverse_end') ? '-' : '+' if line =~# '^\^' && !has_key(state, 'blame_reverse_end')
let cmd = s:Open((s:BlameBufnr() < 0 ? '' : &splitbelow ? "botright " : "topleft ") . a:cmd, 0, '', commit, [commit]) let path = commit . ':' . path
return s:Open(mods . a:cmd, 0, '', '+' . lnum . ' ' . s:fnameescape(path), ['+' . lnum, path])
endif
let cmd = s:Open(mods . a:cmd, 0, '', commit, [commit])
if cmd =~# '^echoerr' if cmd =~# '^echoerr'
return cmd return cmd
endif endif

View File

@ -199,11 +199,13 @@ that are part of Git repositories).
A resize to end of author column A resize to end of author column
C resize to end of commit column C resize to end of commit column
D resize to end of date/time column D resize to end of date/time column
gq close blame, then |:Gedit| to return to work tree version gq close blame, then |:Gedit| to return to work
<CR> close blame, then open commit tree version
o open commit in horizontal split <CR> close blame, and jump to patch that added line
O open commit in new tab (or directly to blob for boundary commit)
p open commit in preview window o jump to patch or blob in horizontal split
O jump to patch or blob in new tab
p jump to patch or blob in preview window
- reblame at commit - reblame at commit
~ reblame at [count]th first grandparent ~ reblame at [count]th first grandparent
P reblame at [count]th parent (like HEAD^[count]) P reblame at [count]th parent (like HEAD^[count])