diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index c6b5401..e34af76 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1653,6 +1653,13 @@ function! s:GF(mode) abort 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\)') + let dcmd = 'Gdiff' + + elseif getline('.') =~# '^index ' && getline(line('.')-1) =~# '^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)' + let line = getline(line('.')-1) + let dref = matchstr(line,'\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)') + let ref = matchstr(line,'\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)') + let dcmd = 'Gdiff!' elseif line('$') == 1 && getline('.') =~ '^\x\{40\}$' let ref = getline('.') @@ -1680,7 +1687,7 @@ function! s:GF(mode) abort endif if exists('dref') - return s:Edit(a:mode,ref) . '|Gdiff '.s:fnameescape(dref) + return s:Edit(a:mode,ref) . '|'.dcmd.' '.s:fnameescape(dref) elseif ref != "" return s:Edit(a:mode,ref) endif