summaryrefslogtreecommitdiffstats
path: root/git_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'git_config.py')
-rw-r--r--git_config.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/git_config.py b/git_config.py
index 75936d40..dc209ba8 100644
--- a/git_config.py
+++ b/git_config.py
@@ -359,10 +359,14 @@ class RefSpec(object):
359_ssh_cache = {} 359_ssh_cache = {}
360_ssh_master = True 360_ssh_master = True
361 361
362def _open_ssh(host, port): 362def _open_ssh(host, port=None):
363 global _ssh_master 363 global _ssh_master
364 364
365 key = '%s:%s' % (host, port) 365 if port is not None:
366 key = '%s:%s' % (host, port)
367 else:
368 key = host
369
366 if key in _ssh_cache: 370 if key in _ssh_cache:
367 return True 371 return True
368 372
@@ -375,10 +379,13 @@ def _open_ssh(host, port):
375 379
376 command = ['ssh', 380 command = ['ssh',
377 '-o','ControlPath %s' % ssh_sock(), 381 '-o','ControlPath %s' % ssh_sock(),
378 '-p',str(port),
379 '-M', 382 '-M',
380 '-N', 383 '-N',
381 host] 384 host]
385
386 if port is not None:
387 command[3:3] = ['-p',str(port)]
388
382 try: 389 try:
383 Trace(': %s', ' '.join(command)) 390 Trace(': %s', ' '.join(command))
384 p = subprocess.Popen(command) 391 p = subprocess.Popen(command)
@@ -422,7 +429,7 @@ def _preconnect(url):
422 if ':' in host: 429 if ':' in host:
423 host, port = host.split(':') 430 host, port = host.split(':')
424 else: 431 else:
425 port = 22 432 port = None
426 if scheme in ('ssh', 'git+ssh', 'ssh+git'): 433 if scheme in ('ssh', 'git+ssh', 'ssh+git'):
427 return _open_ssh(host, port) 434 return _open_ssh(host, port)
428 return False 435 return False
@@ -430,7 +437,7 @@ def _preconnect(url):
430 m = URI_SCP.match(url) 437 m = URI_SCP.match(url)
431 if m: 438 if m:
432 host = m.group(1) 439 host = m.group(1)
433 return _open_ssh(host, 22) 440 return _open_ssh(host)
434 441
435 return False 442 return False
436 443