From 389efdcf148ba18edc3cc8b007900ba44ab03527 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 26 Feb 2011 20:55:04 -0500 Subject: [PATCH] Open current branch commits on :Gbrowse HEAD --- plugin/fugitive.vim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 8996c98..b7ea277 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1408,6 +1408,16 @@ function! s:Browse(bang,line1,count,...) abort let type = 'blob' endif endif + if path =~# '^\.git/.*HEAD' && filereadable(s:repo().dir(path[5:-1])) + let body = readfile(s:repo().dir(path[5:-1]))[0] + if body =~# '^\x\{40\}$' + let commit = body + let type = 'commit' + let path = '' + elseif body =~# '^ref: refs/' + let path = '.git/' . matchstr(body,'ref: \zs.*') + endif + endif if a:0 && a:1 =~# '@[[:alnum:]_-]*\%(://.\{-\}\)\=$' let remote = matchstr(a:1,'@\zs[[:alnum:]_-]\+\%(://.\{-\}\)\=$') @@ -1416,9 +1426,7 @@ function! s:Browse(bang,line1,count,...) abort else let remote = 'origin' let branch = matchstr(rev,'^[[:alnum:]/._-]\+\ze[:^~@]') - if branch =~# 'HEAD$' && filereadable(s:repo().dir(branch)) - let branch = matchstr(readfile(s:repo().dir(branch))[0],'\