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 51569b5ea27c38afcd2c9df076e517e5441ac41f (tree)
parent db535978f10d68e9bc1aeb926ba27cc2e0c78122
Author: Tim Pope <code@tpope.net>
Date:   Sun, 18 Oct 2009 18:12:36 -0400

Jump on a rename or "diff --git" line

Diffstat:
Mplugin/fugitive.vim | 24++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim @@ -1151,15 +1151,33 @@ function! s:GF(mode) abort elseif getline('.') =~# '^[+-]\{3\} [ab/]' let ref = getline('.')[4:] + elseif getline('.') =~# '^rename from ' + let ref = 'a/'.getline('.')[12:] + elseif getline('.') =~# '^rename to ' + let ref = 'b/'.getline('.')[10:] + + elseif getline('.') =~# '^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)' + let dref = matchstr(getline('.'),'\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)') + let ref = matchstr(getline('.'),'\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)') + elseif line('$') == 1 && getline('.') =~ '^\x\{40\}$' let ref = getline('.') else let ref = '' endif - if myhash != '' + if myhash ==# '' + let ref = s:sub(ref,'^a/','HEAD:') + let ref = s:sub(ref,'^b/',':0:') + if exists('dref') + let dref = s:sub(dref,'^a/','HEAD:') + endif + else let ref = s:sub(ref,'^a/',myhash.'^:') let ref = s:sub(ref,'^b/',myhash.':') + if exists('dref') + let dref = s:sub(dref,'^a/',myhash.'^:') + endif endif if ref == '/dev/null' @@ -1167,7 +1185,9 @@ function! s:GF(mode) abort let ref = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391' endif - if ref != "" + if exists('dref') + return s:Edit(a:mode,ref) . '|Gdiff '.s:fnameescape(dref) + elseif ref != "" return s:Edit(a:mode,ref) endif