motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit acfcb068ed210ce013a726da950b44be41391b90 (tree)
parent 6f0ff0ed009f6eb915cd5b012ee6011f8c568e5c
Author: Tim Pope <code@tpope.net>
Date:   Sun, 29 Aug 2021 11:15:11 -0400

Don't append another filename when expanding ">commit:file"

This opens up the possibility of using ">" to navigate to a renamed
version of a file, for example.

Diffstat:
Mautoload/fugitive.vim | 18++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim @@ -1804,14 +1804,20 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort endfunction function! s:Expand(rev, ...) abort - if a:rev =~# '^:[0-3]$' - let file = len(expand('%')) ? a:rev . ':%' : '%' + if a:rev =~# '^>\=:[0-3]$' + let file = len(expand('%')) ? a:rev[-2:-1] . ':%' : '%' elseif a:rev ==# '>' let file = '%' - elseif a:rev =~# '^>[~^]' - let file = len(expand('%')) ? '!' . a:rev[1:-1] . ':%' : '%' + elseif a:rev ==# '>:' + let file = empty(s:DirCommitFile(@%)[0]) ? ':0:%' : '%' elseif a:rev =~# '^>[> ]\@!' - let file = len(expand('%')) ? a:rev[1:-1] . ':%' : '%' + let rev = (a:rev =~# '^>[~^]' ? '!' : '') . a:rev[1:-1] + let prefix = matchstr(rev, '^\%(\\.\|{[^{}]*}\|[^:]\)*') + if prefix !=# rev + let file = rev + else + let file = len(expand('%')) ? rev . ':%' : '%' + endif else let file = a:rev endif @@ -5676,7 +5682,7 @@ function! s:OpenParse(string, wants_cmd) abort break endif endwhile - if len(args) + if len(args) && args !=# ['>:'] let file = join(args) if file ==# '-' let result = fugitive#Result()