commit 5ba918ea7b1dff196c64872bd72cdcf5bc052dff (tree)
parent 27475a5d083b3a6a94ab7cfe1f0ae0e110c75d97
Author: Tim Pope <code@tpope.net>
Date: Mon, 16 Jul 2018 18:00:00 -0400
Support :Gread commit to read commit message
Diffstat:
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -444,7 +444,7 @@ call s:add_methods('repo',['keywordprg'])
" Section: Buffer
function! s:DirCommitFile(path) abort
- let vals = matchlist(s:shellslash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\w\+\)\(/.*\)\=$')
+ let vals = matchlist(s:shellslash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
if empty(vals)
return ['', '', '']
endif
@@ -2785,21 +2785,16 @@ function! fugitive#BufReadStatus() abort
endfunction
function! fugitive#FileRead() abort
- try
- let [dir, commit, file] = s:DirCommitFile(expand('<amatch>'))
- let repo = s:repo(dir)
- let path = commit . substitute(file, '^/', ':', '')
- let hash = repo.rev_parse(path)
- if path =~ '^:'
- let type = 'blob'
- else
- let type = repo.git_chomp('cat-file','-t',hash)
- endif
- " TODO: use count, if possible
- return "read !".escape(repo.git_command('cat-file',type,hash),'%#\')
- catch /^fugitive:/
- return 'echoerr v:errmsg'
- endtry
+ let [dir, rev] = s:DirRev(expand('<amatch>'))
+ if empty(dir)
+ return "noautocmd '[read <amatch>"
+ endif
+ if rev !~# ':'
+ let cmd = fugitive#Prepare(dir, 'log', '--pretty=format:%B', '-1', rev)
+ else
+ let cmd = fugitive#Prepare(dir, 'cat-file', '-p', rev)
+ endif
+ return "'[read !" . escape(cmd, '!#%')
endfunction
function! fugitive#BufReadIndex() abort
@@ -2940,10 +2935,6 @@ function! fugitive#BufReadObject() abort
endtry
endfunction
-augroup fugitive_files
- autocmd!
-augroup END
-
" Section: Temp files
if !exists('s:temp_files')