summaryrefslogtreecommitdiffstats
path: root/git_config.py
diff options
context:
space:
mode:
authorJosh Guilfoyle <jasta00@gmail.com>2009-08-16 09:44:40 -0700
committerShawn O. Pearce <sop@google.com>2010-06-08 11:08:11 -0700
commit7198572dd7f5b9d95d83733a98691948a3eb9da3 (patch)
tree49b9a3967d575d51b92d44a1c2ce0bb3449faa41 /git_config.py
parent2daf66740bba0b2726462a547910d16cf0822db2 (diff)
downloadgit-repo-7198572dd7f5b9d95d83733a98691948a3eb9da3.tar.gz
Do not invoke ssh with -p argument when no port has been specified.
This change allows local SSH configuration to choose the port number to use when not explicitly set in the manifest. (cherry picked from commit 4c0f67046543c7c6ab24175e143001f14b76ea01) Change-Id: Ibea99cfe46b6a2cc27f754cc3944a2fe10f6fda4
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