From a09e49d2bba074a4cc37ed850a556b3604837ff8 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Thu, 8 Aug 2019 20:20:45 -0400 Subject: [PATCH] Support :Gblame --reverse Closes https://github.com/tpope/vim-fugitive/issues/1305 --- autoload/fugitive.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index e703693..bb429ad 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -4615,18 +4615,19 @@ function! s:BlameCommand(line1, line2, range, count, bang, mods, reg, arg, args) if empty(s:Relative('/')) call s:throw('file or blob required') endif + let commit = matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$') if filter(copy(a:args),'v:val !~# "^-"') != [] call s:throw("'-' required for all options") - elseif filter(copy(a:args),'v:val !~# "^\\%(--abbrev=\\d*\\|--relative-date\\|--first-parent\\|--root\\|--show-name\\|-\\%([ltfnsew]\\|[MC]\\d*\\)\\+\\)$"') != [] - call s:throw('unsupported option') + elseif filter(copy(a:args),'v:val !~# "^\\%(--abbrev=\\d*\\|--relative-date\\|--first-parent\\|--root\\|--show-name' . (len(commit) ? '\\|--reverse' : '') . '\\|-\\%([ltfnsew]\\|[MC]\\d*\\)\\+\\)$"') != [] + call s:throw('unsupported option' . commit) endif let cmd = ['--no-pager', '-c', 'blame.coloring=none', 'blame', '--show-number'] if a:count > 0 let cmd += ['-L', (a:line1 ? a:line1 : line('.')) . ',' . (a:line1 ? a:line1 : line('.'))] endif let cmd += a:args - if s:DirCommitFile(@%)[1] =~# '\D\|..' - let cmd += [s:DirCommitFile(@%)[1]] + if len(commit) + let cmd += [commit] else let cmd += ['--contents', '-'] endif