mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -05:00
Support :GBrowse with paths outside current repo
Resolves: https://github.com/tpope/vim-fugitive/issues/2144
This commit is contained in:
@@ -7379,12 +7379,13 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
||||
endfor
|
||||
return 'echoerr ' . string('fugitive: no URL found in output of :Git')
|
||||
endif
|
||||
exe s:DirCheck(dir)
|
||||
if empty(remote) && expanded =~# '^[^-./:^~][^:^~]*$' && !empty(dir)
|
||||
let config = fugitive#Config(dir)
|
||||
if empty(remote) && expanded =~# '^[^-./:^~][^:^~]*$' && !empty(FugitiveConfigGet('remote.' . expanded . '.url', config))
|
||||
if !empty(FugitiveConfigGet('remote.' . expanded . '.url', config))
|
||||
let remote = expanded
|
||||
let expanded = ''
|
||||
endif
|
||||
endif
|
||||
if empty(expanded)
|
||||
let bufname = &buftype =~# '^\%(nofile\|terminal\)$' ? '' : s:BufName('%')
|
||||
let expanded = s:DirRev(bufname)[1]
|
||||
@@ -7419,17 +7420,22 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
||||
endif
|
||||
endif
|
||||
let path = path[1:-1]
|
||||
elseif empty(s:Tree(dir))
|
||||
let path = '.git/' . full[strlen(dir)+1:-1]
|
||||
let type = ''
|
||||
else
|
||||
let path = fugitive#Path(full, '/')[1:-1]
|
||||
elseif !empty(s:Tree(dir))
|
||||
let relevant_dir = FugitiveExtractGitDir(full)
|
||||
if !empty(relevant_dir)
|
||||
let dir = relevant_dir
|
||||
endif
|
||||
let path = fugitive#Path(full, '/', dir)[1:-1]
|
||||
if empty(path) || isdirectory(full)
|
||||
let type = 'tree'
|
||||
else
|
||||
let type = 'blob'
|
||||
endif
|
||||
else
|
||||
let path = '.git/' . full[strlen(dir)+1:-1]
|
||||
let type = ''
|
||||
endif
|
||||
exe s:DirCheck(dir)
|
||||
if path =~# '^\.git/'
|
||||
let ref = matchstr(path, '^.git/\zs\%(refs/[^/]\+/[^/].*\|\w*HEAD\)$')
|
||||
let type = empty(ref) ? 'root': 'ref'
|
||||
@@ -7447,6 +7453,9 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
||||
endif
|
||||
endif
|
||||
|
||||
if !exists('l:config') || s:Dir(config) !=# dir
|
||||
let config = fugitive#Config(dir)
|
||||
endif
|
||||
let merge = ''
|
||||
if !empty(remote) && ref =~# '^refs/remotes/[^/]\+/[^/]\|^refs/heads/[^/]'
|
||||
let merge = matchstr(ref, '^refs/\%(heads/\|remotes/[^/]\+/\)\zs.\+')
|
||||
|
||||
Reference in New Issue
Block a user