Don't assume buffer().commit() is a hash or stage

This commit is contained in:
Tim Pope 2009-11-11 00:16:02 -05:00
parent 4e77ba13c6
commit 9f6af8031c

View File

@ -388,10 +388,10 @@ function! s:buffer_expand(rev) dict abort
endfunction endfunction
function! s:buffer_containing_commit() dict abort function! s:buffer_containing_commit() dict abort
if self.commit() =~# '\x\{40\}' if self.commit() =~# '^\d$'
return self.commit()
elseif self.commit() =~# '.'
return ':' return ':'
elseif self.commit() =~# '.'
return self.commit()
else else
return 'HEAD' return 'HEAD'
endif endif
@ -888,7 +888,7 @@ function! s:Blame(bang,line1,line2,count) abort
endif endif
let git_dir = s:repo().dir() let git_dir = s:repo().dir()
let cmd = ['--no-pager', 'blame', '--show-number'] let cmd = ['--no-pager', 'blame', '--show-number']
if strlen(s:buffer().commit()) == 40 if s:buffer().commit() =~# '\D\|..'
let cmd += [s:buffer().commit()] let cmd += [s:buffer().commit()]
else else
let cmd += ['--contents', '-'] let cmd += ['--contents', '-']