mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 05:43:52 -05:00
Fix handling of Include in SSH config
The Include directive behaves very literally. The old implementation assumed a level of encapsulation that just doesn't match the actual implementation.
This commit is contained in:
@@ -1235,12 +1235,15 @@ function! s:SshParseHost(value) abort
|
|||||||
return '^\%(' . join(patterns, '\|') . '\)$' . join(negates, '')
|
return '^\%(' . join(patterns, '\|') . '\)$' . join(negates, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SshParseConfig(into, root, file, ...) abort
|
function! s:SshParseConfig(into, root, file) abort
|
||||||
if !filereadable(a:file)
|
try
|
||||||
|
let lines = readfile(a:file)
|
||||||
|
catch
|
||||||
return a:into
|
return a:into
|
||||||
endif
|
endtry
|
||||||
let host = a:0 ? a:1 : '^\%(.*\)$'
|
let host = '^\%(.*\)$'
|
||||||
for line in readfile(a:file)
|
while !empty(lines)
|
||||||
|
let line = remove(lines, 0)
|
||||||
let key = tolower(matchstr(line, '^\s*\zs\w\+\ze\s'))
|
let key = tolower(matchstr(line, '^\s*\zs\w\+\ze\s'))
|
||||||
let value = matchstr(line, '^\s*\w\+\s\+\zs.*\S')
|
let value = matchstr(line, '^\s*\w\+\s\+\zs.*\S')
|
||||||
if key ==# 'match'
|
if key ==# 'match'
|
||||||
@@ -1248,26 +1251,22 @@ function! s:SshParseConfig(into, root, file, ...) abort
|
|||||||
elseif key ==# 'host'
|
elseif key ==# 'host'
|
||||||
let host = s:SshParseHost(value)
|
let host = s:SshParseHost(value)
|
||||||
elseif key ==# 'include'
|
elseif key ==# 'include'
|
||||||
call s:SshParseInclude(a:into, a:root, host, value)
|
for glob in split(value)
|
||||||
|
if glob !~# '^/'
|
||||||
|
let glob = a:root . glob
|
||||||
|
endif
|
||||||
|
for included in reverse(split(glob(glob), "\n"))
|
||||||
|
call extend(lines, readfile(included), 'keep')
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
elseif len(key) && len(host)
|
elseif len(key) && len(host)
|
||||||
call extend(a:into, {key : []}, 'keep')
|
call extend(a:into, {key : []}, 'keep')
|
||||||
call add(a:into[key], [host, value])
|
call add(a:into[key], [host, value])
|
||||||
endif
|
endif
|
||||||
endfor
|
endwhile
|
||||||
return a:into
|
return a:into
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SshParseInclude(into, root, host, value) abort
|
|
||||||
for glob in split(a:value)
|
|
||||||
if glob !~# '^/'
|
|
||||||
let glob = a:root . glob
|
|
||||||
endif
|
|
||||||
for file in split(glob(glob), "\n")
|
|
||||||
call s:SshParseConfig(a:into, a:root, file, a:host)
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
unlet! s:ssh_config
|
unlet! s:ssh_config
|
||||||
function! fugitive#SshConfig(host, ...) abort
|
function! fugitive#SshConfig(host, ...) abort
|
||||||
if !exists('s:ssh_config')
|
if !exists('s:ssh_config')
|
||||||
|
|||||||
Reference in New Issue
Block a user