Open current branch commits on :Gbrowse HEAD

This commit is contained in:
Tim Pope
2011-02-26 20:55:04 -05:00
parent 1e6d7c8a40
commit 389efdcf14

View File

@@ -1408,6 +1408,16 @@ function! s:Browse(bang,line1,count,...) abort
let type = 'blob' let type = 'blob'
endif endif
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:]_-]*\%(://.\{-\}\)\=$' if a:0 && a:1 =~# '@[[:alnum:]_-]*\%(://.\{-\}\)\=$'
let remote = matchstr(a:1,'@\zs[[:alnum:]_-]\+\%(://.\{-\}\)\=$') let remote = matchstr(a:1,'@\zs[[:alnum:]_-]\+\%(://.\{-\}\)\=$')
@@ -1416,9 +1426,7 @@ function! s:Browse(bang,line1,count,...) abort
else else
let remote = 'origin' let remote = 'origin'
let branch = matchstr(rev,'^[[:alnum:]/._-]\+\ze[:^~@]') let branch = matchstr(rev,'^[[:alnum:]/._-]\+\ze[:^~@]')
if branch =~# 'HEAD$' && filereadable(s:repo().dir(branch)) if branch ==# '' && path =~# '^\.git/refs/\w\+/'
let branch = matchstr(readfile(s:repo().dir(branch))[0],'\<refs/heads/\zs.*')
elseif branch ==# '' && path =~# '^\.git/refs/\w\+/'
let branch = s:sub(path,'^\.git/refs/\w+/','') let branch = s:sub(path,'^\.git/refs/\w+/','')
endif endif
if filereadable(s:repo().dir('refs/remotes/'.branch)) if filereadable(s:repo().dir('refs/remotes/'.branch))