summaryrefslogtreecommitdiffstats
path: root/git_config.py
diff options
context:
space:
mode:
authorJosh Guilfoyle <jasta00@gmail.com>2009-08-16 09:44:40 -0700
committerJosh Guilfoyle <jasta00@gmail.com>2009-08-16 11:26:57 -0700
commit4c0f67046543c7c6ab24175e143001f14b76ea01 (patch)
tree4716f6c6a3a05480146fe0fd8189bbeac7862bf9 /git_config.py
parentc24c720b6135a8f7975bf9af265124eee2d464cb (diff)
downloadgit-repo-4c0f67046543c7c6ab24175e143001f14b76ea01.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.
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 e1e20463..fe983c4a 100644
--- a/git_config.py
+++ b/git_config.py
@@ -356,10 +356,14 @@ class RefSpec(object):
356_ssh_cache = {} 356_ssh_cache = {}
357_ssh_master = True 357_ssh_master = True
358 358
359def _open_ssh(host, port): 359def _open_ssh(host, port=None):
360 global _ssh_master 360 global _ssh_master
361 361
362 key = '%s:%s' % (host, port) 362 if port is not None:
363 key = '%s:%s' % (host, port)
364 else:
365 key = host
366
363 if key in _ssh_cache: 367 if key in _ssh_cache:
364 return True 368 return True
365 369
@@ -372,10 +376,13 @@ def _open_ssh(host, port):
372 376
373 command = ['ssh', 377 command = ['ssh',
374 '-o','ControlPath %s' % _ssh_sock(), 378 '-o','ControlPath %s' % _ssh_sock(),
375 '-p',str(port),
376 '-M', 379 '-M',
377 '-N', 380 '-N',
378 host] 381 host]
382
383 if port is not None:
384 command[3:3] = ['-p',str(port)]
385
379 try: 386 try:
380 Trace(': %s', ' '.join(command)) 387 Trace(': %s', ' '.join(command))
381 p = subprocess.Popen(command) 388 p = subprocess.Popen(command)
@@ -417,7 +424,7 @@ def _preconnect(url):
417 if ':' in host: 424 if ':' in host:
418 host, port = host.split(':') 425 host, port = host.split(':')
419 else: 426 else:
420 port = 22 427 port = None
421 if scheme in ('ssh', 'git+ssh', 'ssh+git'): 428 if scheme in ('ssh', 'git+ssh', 'ssh+git'):
422 return _open_ssh(host, port) 429 return _open_ssh(host, port)
423 return False 430 return False
@@ -425,7 +432,7 @@ def _preconnect(url):
425 m = URI_SCP.match(url) 432 m = URI_SCP.match(url)
426 if m: 433 if m:
427 host = m.group(1) 434 host = m.group(1)
428 return _open_ssh(host, 22) 435 return _open_ssh(host)
429 436
430 return False 437 return False
431 438