From c2877d0d5cf1f9aefd91b2821b89f44ce1b7174d Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 28 Jun 2014 23:22:00 -0400 Subject: [PATCH] Show commit message in :Gblame statusline References #405. --- plugin/fugitive.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 8eb90c6..2db87ab 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -2049,6 +2049,7 @@ function! s:Blame(bang,line1,line2,count,args) abort if exists('+relativenumber') setlocal norelativenumber endif + let &l:statusline = '%{fugitive#blame_statusline('.bufnr('').')}%<' execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1) nnoremap :help fugitive-:Gblame nnoremap g? :help fugitive-:Gblame @@ -2216,6 +2217,25 @@ function! s:RehighlightBlame() abort endfor 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 call s:command("-bar -bang -range=0 -nargs=* -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(0,,,)")