summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-04-21 14:51:04 -0700
committerShawn O. Pearce <sop@google.com>2009-04-21 14:51:04 -0700
commit896d5dffd313a2ad91fd8bee750241a6512b25dc (patch)
treec2f11ce9393b2f27cff759578cad6bb5c7bdf486
parent9360966bd2ff68fd7257b50df1a7fcb5e62fe189 (diff)
downloadgit-repo-896d5dffd313a2ad91fd8bee750241a6512b25dc.tar.gz
Fix UnboundLocalError: local variable 'port' when using SSHv1.6.7.2
If the SSH URL doesn't contain a port number, but uses the ssh:// or git+ssh:// syntax we raised a Python runtime error due to the 'port' local variable not being assigned a value. Default it to the IANA assigned port for SSH, 22. Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--git_config.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/git_config.py b/git_config.py
index 163b0809..53b52c85 100644
--- a/git_config.py
+++ b/git_config.py
@@ -337,12 +337,9 @@ class RefSpec(object):
337_ssh_cache = {} 337_ssh_cache = {}
338_ssh_master = True 338_ssh_master = True
339 339
340def _open_ssh(host, port=None): 340def _open_ssh(host, port):
341 global _ssh_master 341 global _ssh_master
342 342
343 if port is None:
344 port = 22
345
346 key = '%s:%s' % (host, port) 343 key = '%s:%s' % (host, port)
347 if key in _ssh_cache: 344 if key in _ssh_cache:
348 return True 345 return True
@@ -397,6 +394,8 @@ def _preconnect(url):
397 host = m.group(2) 394 host = m.group(2)
398 if ':' in host: 395 if ':' in host:
399 host, port = host.split(':') 396 host, port = host.split(':')
397 else:
398 port = 22
400 if scheme in ('ssh', 'git+ssh', 'ssh+git'): 399 if scheme in ('ssh', 'git+ssh', 'ssh+git'):
401 return _open_ssh(host, port) 400 return _open_ssh(host, port)
402 return False 401 return False
@@ -404,7 +403,7 @@ def _preconnect(url):
404 m = URI_SCP.match(url) 403 m = URI_SCP.match(url)
405 if m: 404 if m:
406 host = m.group(1) 405 host = m.group(1)
407 return _open_ssh(host) 406 return _open_ssh(host, 22)
408 407
409 408
410class Remote(object): 409class Remote(object):