mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Merge change 11206
* change 11206: Do not invoke ssh with -p argument when no port has been specified.
This commit is contained in:
commit
0afac0856c
@ -366,10 +366,14 @@ class RefSpec(object):
|
|||||||
_ssh_cache = {}
|
_ssh_cache = {}
|
||||||
_ssh_master = True
|
_ssh_master = True
|
||||||
|
|
||||||
def _open_ssh(host, port):
|
def _open_ssh(host, port=None):
|
||||||
global _ssh_master
|
global _ssh_master
|
||||||
|
|
||||||
key = '%s:%s' % (host, port)
|
if port is not None:
|
||||||
|
key = '%s:%s' % (host, port)
|
||||||
|
else:
|
||||||
|
key = host
|
||||||
|
|
||||||
if key in _ssh_cache:
|
if key in _ssh_cache:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -382,10 +386,13 @@ def _open_ssh(host, port):
|
|||||||
|
|
||||||
command = ['ssh',
|
command = ['ssh',
|
||||||
'-o','ControlPath %s' % _ssh_sock(),
|
'-o','ControlPath %s' % _ssh_sock(),
|
||||||
'-p',str(port),
|
|
||||||
'-M',
|
'-M',
|
||||||
'-N',
|
'-N',
|
||||||
host]
|
host]
|
||||||
|
|
||||||
|
if port is not None:
|
||||||
|
command[3:3] = ['-p',str(port)]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Trace(': %s', ' '.join(command))
|
Trace(': %s', ' '.join(command))
|
||||||
p = subprocess.Popen(command)
|
p = subprocess.Popen(command)
|
||||||
@ -427,7 +434,7 @@ def _preconnect(url):
|
|||||||
if ':' in host:
|
if ':' in host:
|
||||||
host, port = host.split(':')
|
host, port = host.split(':')
|
||||||
else:
|
else:
|
||||||
port = 22
|
port = None
|
||||||
if scheme in ('ssh', 'git+ssh', 'ssh+git'):
|
if scheme in ('ssh', 'git+ssh', 'ssh+git'):
|
||||||
return _open_ssh(host, port)
|
return _open_ssh(host, port)
|
||||||
return False
|
return False
|
||||||
@ -435,7 +442,7 @@ def _preconnect(url):
|
|||||||
m = URI_SCP.match(url)
|
m = URI_SCP.match(url)
|
||||||
if m:
|
if m:
|
||||||
host = m.group(1)
|
host = m.group(1)
|
||||||
return _open_ssh(host, 22)
|
return _open_ssh(host)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user