Pass :Gblame flags along to git-blame
This commit is contained in:
parent
05c0efacab
commit
9c86a7d379
@ -139,11 +139,13 @@ that are part of Git repositories).
|
||||
buffer.
|
||||
|
||||
*fugitive-:Gblame*
|
||||
:Gblame Run git-blame on the file and open the results in a
|
||||
:Gblame [flags] Run git-blame on the file and open the results in a
|
||||
scroll bound vertical split. Press enter on a line to
|
||||
reblame the file as it was in that commit.
|
||||
reblame the file as it was in that commit. You can
|
||||
give any of ltwfsMC as flags and they will be passed
|
||||
along to git-blame.
|
||||
|
||||
:[range]Gblame Run git-blame on the given range.
|
||||
:[range]Gblame [flags] Run git-blame on the given range.
|
||||
|
||||
MAPPINGS *fugitive-mappings*
|
||||
|
||||
|
@ -1120,16 +1120,20 @@ augroup fugitive_blame
|
||||
autocmd BufReadPost *.fugitiveblame setfiletype fugitiveblame
|
||||
autocmd FileType fugitiveblame setlocal nomodeline | if exists('b:git_dir') | let &l:keywordprg = s:repo().keywordprg() | endif
|
||||
autocmd Syntax fugitiveblame call s:BlameSyntax()
|
||||
autocmd User Fugitive if s:buffer().type('file', 'blob') | exe "command! -buffer -bar -bang -range=0 Gblame :execute s:Blame(<bang>0,<line1>,<line2>,<count>,<f-args>)" | endif
|
||||
autocmd User Fugitive if s:buffer().type('file', 'blob') | exe "command! -buffer -bar -bang -range=0 -nargs=* Gblame :execute s:Blame(<bang>0,<line1>,<line2>,<count>,[<f-args>])" | endif
|
||||
augroup END
|
||||
|
||||
function! s:Blame(bang,line1,line2,count) abort
|
||||
function! s:Blame(bang,line1,line2,count,args) abort
|
||||
try
|
||||
if s:buffer().path() == ''
|
||||
call s:throw('file or blob required')
|
||||
endif
|
||||
if filter(copy(a:args),'v:val !~# "^\\%(--root\|--show-name\\|-\\=\\%([ltwfs]\\|[MC]\\d*\\)\\+\\)$"') != []
|
||||
call s:throw('unsupported option')
|
||||
endif
|
||||
call map(a:args,'s:sub(v:val,"^\\ze[^-]","-")')
|
||||
let git_dir = s:repo().dir()
|
||||
let cmd = ['--no-pager', 'blame', '--show-number']
|
||||
let cmd = ['--no-pager', 'blame', '--show-number'] + a:args
|
||||
if s:buffer().commit() =~# '\D\|..'
|
||||
let cmd += [s:buffer().commit()]
|
||||
else
|
||||
@ -1169,6 +1173,7 @@ function! s:Blame(bang,line1,line2,count) abort
|
||||
let b:fugitive_type = 'blame'
|
||||
let b:fugitive_blamed_bufnr = bufnr
|
||||
let b:fugitive_restore = restore
|
||||
let b:fugitive_blame_arguments = join(a:args,' ')
|
||||
call s:Detect(expand('%:p'))
|
||||
execute top
|
||||
normal! zt
|
||||
@ -1199,11 +1204,12 @@ function! s:BlameJump(suffix) abort
|
||||
if commit =~# '^0\+$'
|
||||
let commit = ':0'
|
||||
endif
|
||||
let lnum = matchstr(getline('.'),'\d\+\ze (')
|
||||
let path = matchstr(getline('.'),'^\^\=\zs\x\+\s\+\zs.\{-\}\ze\s*\d\+ (')
|
||||
let lnum = matchstr(getline('.'),'\d\+\ze\s\+[([:digit:]]')
|
||||
let path = matchstr(getline('.'),'^\^\=\zs\x\+\s\+\zs.\{-\}\ze\s*\d\+ ')
|
||||
if path ==# ''
|
||||
let path = s:buffer(b:fugitive_blamed_bufnr).path()
|
||||
endif
|
||||
let args = b:fugitive_blame_arguments
|
||||
let offset = line('.') - line('w0')
|
||||
let bufnr = bufnr('%')
|
||||
let winnr = bufwinnr(b:fugitive_blamed_bufnr)
|
||||
@ -1214,7 +1220,7 @@ function! s:BlameJump(suffix) abort
|
||||
if winnr > 0
|
||||
exe bufnr.'bdelete'
|
||||
endif
|
||||
Gblame
|
||||
execute 'Gblame '.args
|
||||
execute lnum
|
||||
let delta = line('.') - line('w0') - offset
|
||||
if delta > 0
|
||||
@ -1229,13 +1235,16 @@ endfunction
|
||||
function! s:BlameSyntax() abort
|
||||
let b:current_syntax = 'fugitiveblame'
|
||||
syn match FugitiveblameBoundary "^\^"
|
||||
syn match FugitiveblameHash "\%(^\^\=\)\@<=\x\{7,40\}\>" nextgroup=FugitiveblameAnnotation,fugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite
|
||||
syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,fugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite
|
||||
syn match FugitiveblameHash "\%(^\^\=\)\@<=\x\{7,40\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite
|
||||
syn match FugitiveblameUncommitted "\%(^\^\=\)\@<=0\{7,40\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite
|
||||
syn region FugitiveblameAnnotation matchgroup=FugitiveblameDelimiter start="(" end="\%( \d\+\)\@<=)" contained keepend oneline
|
||||
syn match FugitiveblameTime "[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%( \+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation
|
||||
syn match FugitiveblameLineNumber " \@<=\d\+)\@=" contained containedin=FugitiveblameAnnotation
|
||||
syn match FugitiveblameOriginalFile " \%(\f\+\D\@<=\|\D\@=\f\+\)\%(\%(\s\+\d\+\)\= (\)\@=" contained nextgroup=FugitiveblameOriginalLineNumber,FugitiveblameAnnotation skipwhite
|
||||
syn match FugitiveblameOriginalLineNumber " \@<=\d\+\%( (\)\@=" contained nextgroup=FugitiveblameAnnotation skipwhite
|
||||
syn match FugitiveblameOriginalFile " \%(\f\+\D\@<=\|\D\@=\f\+\)\%(\%(\s\+\d\+\)\=\s\%((\|\s*\d\+)\)\)\@=" contained nextgroup=FugitiveblameOriginalLineNumber,FugitiveblameAnnotation skipwhite
|
||||
syn match FugitiveblameOriginalLineNumber " \@<=\d\+\%(\s(\)\@=" contained nextgroup=FugitiveblameAnnotation skipwhite
|
||||
syn match FugitiveblameOriginalLineNumber " \@<=\d\+\%(\s\+\d\+)\)\@=" contained nextgroup=FugitiveblameShort skipwhite
|
||||
syn match FugitiveblameShort "\d\+)" contained contains=FugitiveblameLineNumber
|
||||
syn match FugitiveblameNotCommittedYet "(\@<=Not Committed Yet\>" contained containedin=FugitiveblameAnnotation
|
||||
hi def link FugitiveblameBoundary Keyword
|
||||
hi def link FugitiveblameHash Identifier
|
||||
@ -1244,6 +1253,7 @@ function! s:BlameSyntax() abort
|
||||
hi def link FugitiveblameLineNumber Number
|
||||
hi def link FugitiveblameOriginalFile String
|
||||
hi def link FugitiveblameOriginalLineNumber Float
|
||||
hi def link FugitiveblameShort FugitiveblameDelimiter
|
||||
hi def link FugitiveblameDelimiter Delimiter
|
||||
hi def link FugitiveblameNotCommittedYet Comment
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user