mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-10 04:23:46 -05:00
Fix expansion of SSH host aliases
Resolves: https://github.com/tpope/vim-fugitive/issues/1962
This commit is contained in:
@@ -1246,6 +1246,7 @@ function! fugitive#RemoteHttpHeaders(remote) abort
|
|||||||
if type(remote) !=# type('') || remote !~# '^https\=://.' || !s:executable('curl')
|
if type(remote) !=# type('') || remote !~# '^https\=://.' || !s:executable('curl')
|
||||||
return {}
|
return {}
|
||||||
endif
|
endif
|
||||||
|
let remote = substitute(remote, '#.*', '', '')
|
||||||
if !has_key(s:remote_headers, remote)
|
if !has_key(s:remote_headers, remote)
|
||||||
let url = remote . '/info/refs?service=git-upload-pack'
|
let url = remote . '/info/refs?service=git-upload-pack'
|
||||||
let exec = s:JobExecute(
|
let exec = s:JobExecute(
|
||||||
@@ -1274,6 +1275,11 @@ function! s:UrlParse(url) abort
|
|||||||
let url.path = empty(match[3]) ? '/' : match[3]
|
let url.path = empty(match[3]) ? '/' : match[3]
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
return url
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:UrlPopulate(string, into) abort
|
||||||
|
let url = a:into
|
||||||
let url.protocol = substitute(url.scheme, '.\zs$', ':', '')
|
let url.protocol = substitute(url.scheme, '.\zs$', ':', '')
|
||||||
let url.user = matchstr(url.authority, '.\{-\}\ze@', '', '')
|
let url.user = matchstr(url.authority, '.\{-\}\ze@', '', '')
|
||||||
let url.host = substitute(url.authority, '.\{-\}@', '', '')
|
let url.host = substitute(url.authority, '.\{-\}@', '', '')
|
||||||
@@ -1292,16 +1298,15 @@ function! s:UrlParse(url) abort
|
|||||||
elseif url.scheme ==# 'ssh' && url.authority !~# ':'
|
elseif url.scheme ==# 'ssh' && url.authority !~# ':'
|
||||||
let url.href = url.authority . ':' . url.path . url.hash
|
let url.href = url.authority . ':' . url.path . url.hash
|
||||||
else
|
else
|
||||||
let url.href = a:url
|
let url.href = a:string
|
||||||
endif
|
endif
|
||||||
let url.url = matchstr(url.href, '^[^#]*')
|
let url.url = matchstr(url.href, '^[^#]*')
|
||||||
return url
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:RemoteResolve(url, flags) abort
|
function! s:RemoteResolve(url, flags) abort
|
||||||
let remote = s:UrlParse(a:url)
|
let remote = s:UrlParse(a:url)
|
||||||
if remote.scheme =~# '^https\=$' && index(a:flags, ':nohttp') < 0
|
if remote.scheme =~# '^https\=$' && index(a:flags, ':nohttp') < 0
|
||||||
let headers = fugitive#RemoteHttpHeaders(remote.url)
|
let headers = fugitive#RemoteHttpHeaders(a:url)
|
||||||
let loc = matchstr(get(headers, 'location', ''), '^https\=://.\{-\}\ze/info/refs?')
|
let loc = matchstr(get(headers, 'location', ''), '^https\=://.\{-\}\ze/info/refs?')
|
||||||
if len(loc)
|
if len(loc)
|
||||||
let remote = s:UrlParse(loc)
|
let remote = s:UrlParse(loc)
|
||||||
@@ -1347,6 +1352,7 @@ function! s:RemoteCallback(config, into, flags, cb) abort
|
|||||||
else
|
else
|
||||||
call extend(a:into, s:UrlParse(url))
|
call extend(a:into, s:UrlParse(url))
|
||||||
endif
|
endif
|
||||||
|
call s:UrlPopulate(url, a:into)
|
||||||
if len(a:cb)
|
if len(a:cb)
|
||||||
call call(a:cb[0], [a:into] + a:cb[1:-1])
|
call call(a:cb[0], [a:into] + a:cb[1:-1])
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user