From 51569b5ea27c38afcd2c9df076e517e5441ac41f Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 18 Oct 2009 18:12:36 -0400 Subject: [PATCH] Jump on a rename or "diff --git" line --- plugin/fugitive.vim | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 77f3793..8463218 100644 --- 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