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