Support :Gblame --reverse

Closes https://github.com/tpope/vim-fugitive/issues/1305
This commit is contained in:
Tim Pope 2019-08-08 20:20:45 -04:00
parent cce9ca0933
commit a09e49d2bb

View File

@ -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