Merge change 11206
* change 11206:
Do not invoke ssh with -p argument when no port has been specified.
diff --git a/git_config.py b/git_config.py
index b47bc66..9dba699 100644
--- a/git_config.py
+++ b/git_config.py
@@ -366,10 +366,14 @@
_ssh_cache = {}
_ssh_master = True
-def _open_ssh(host, port):
+def _open_ssh(host, port=None):
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:
return True
@@ -382,10 +386,13 @@
command = ['ssh',
'-o','ControlPath %s' % _ssh_sock(),
- '-p',str(port),
'-M',
'-N',
host]
+
+ if port is not None:
+ command[3:3] = ['-p',str(port)]
+
try:
Trace(': %s', ' '.join(command))
p = subprocess.Popen(command)
@@ -427,7 +434,7 @@
if ':' in host:
host, port = host.split(':')
else:
- port = 22
+ port = None
if scheme in ('ssh', 'git+ssh', 'ssh+git'):
return _open_ssh(host, port)
return False
@@ -435,7 +442,7 @@
m = URI_SCP.match(url)
if m:
host = m.group(1)
- return _open_ssh(host, 22)
+ return _open_ssh(host)
return False