2 Commits

Author SHA1 Message Date
Tim Pope
62c50ff296 Handle .git in file system root
References https://github.com/tpope/vim-fugitive/issues/908
2017-05-07 15:29:01 -04:00
Tim Pope
c2877d0d5c Show commit message in :Gblame statusline
References #405.
2017-05-02 20:52:19 -04:00

View File

@@ -298,6 +298,9 @@ endfunction
function! s:repo_tree(...) dict abort
if self.dir() =~# '/\.git$'
let dir = self.dir()[0:-6]
if dir !~# '/'
let dir .= '/'
endif
else
let dir = s:configured_tree(self.git_dir)
endif
@@ -2049,6 +2052,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 <buffer> <silent> <F1> :help fugitive-:Gblame<CR>
nnoremap <buffer> <silent> g? :help fugitive-:Gblame<CR>
@@ -2216,6 +2220,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(<bang>0,<line1>,<count>,<f-args>)")