Show commit message in :Gblame statusline

References #405.
This commit is contained in:
Tim Pope
2014-06-28 23:22:00 -04:00
parent c640ee78a8
commit c2877d0d5c

View File

@@ -2049,6 +2049,7 @@ function! s:Blame(bang,line1,line2,count,args) abort
if exists('+relativenumber') if exists('+relativenumber')
setlocal norelativenumber setlocal norelativenumber
endif endif
let &l:statusline = '%{fugitive#blame_statusline('.bufnr('').')}%<'
execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1) execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1)
nnoremap <buffer> <silent> <F1> :help fugitive-:Gblame<CR> nnoremap <buffer> <silent> <F1> :help fugitive-:Gblame<CR>
nnoremap <buffer> <silent> g? :help fugitive-:Gblame<CR> nnoremap <buffer> <silent> g? :help fugitive-:Gblame<CR>
@@ -2216,6 +2217,25 @@ function! s:RehighlightBlame() abort
endfor endfor
endfunction endfunction
function! fugitive#blame_statusline(nr) abort
if bufnr('%') != a:nr && !getwinvar(0, '&cursorbind')
return ''
endif
let line = getbufline(a:nr, line('.'))[0]
let hash = matchstr(line, '^\^\=\zs\x\{7}')
if hash =~# '^0*$'
return ''
endif
if type(getbufvar(a:nr, 'fugitive_blame_lookup')) != type({})
call setbufvar(a:nr, 'fugitive_blame_lookup', {})
endif
let lookup = getbufvar(a:nr, 'fugitive_blame_lookup')
if !has_key(lookup, hash)
let lookup[hash] = s:repo().git_chomp('log', '-1', hash, '--pretty=format:'.g:fugitive_summary_format)
endif
return get(lookup, hash, '')
endfunction
" Section: Gbrowse " Section: Gbrowse
call s:command("-bar -bang -range=0 -nargs=* -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)") call s:command("-bar -bang -range=0 -nargs=* -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")