From 753318ef83b685f32c6bda5ae5b65b7b239a29a7 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 5 Mar 2021 12:15:57 -0500 Subject: [PATCH] Smarter diff jumping in :Git log Closes https://github.com/tpope/vim-fugitive/issues/1689 --- autoload/fugitive.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 14e24d0..855a4ac 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -6131,8 +6131,15 @@ function! s:cfile() abort let myhash = '' endtry endif - if empty(myhash) && getline(1) =~# '^\%(commit\|tag\) \w' - let myhash = matchstr(getline(1),'^\w\+ \zs\S\+') + if empty(myhash) && get(s:TempState(), 'filetype', '') ==# 'git' + let lnum = line('.') + while lnum > 0 + if getline(lnum) =~# '^\%(commit\|tag\) \w' + let myhash = matchstr(getline(lnum),'^\w\+ \zs\S\+') + break + endif + let lnum -= 1 + endwhile endif let showtree = (getline(1) =~# '^tree ' && getline(2) == "")