diff options
-rw-r--r-- | git_config.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/git_config.py b/git_config.py index b47bc66f..9dba699a 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -366,10 +366,14 @@ class RefSpec(object): | |||
366 | _ssh_cache = {} | 366 | _ssh_cache = {} |
367 | _ssh_master = True | 367 | _ssh_master = True |
368 | 368 | ||
369 | def _open_ssh(host, port): | 369 | def _open_ssh(host, port=None): |
370 | global _ssh_master | 370 | global _ssh_master |
371 | 371 | ||
372 | key = '%s:%s' % (host, port) | 372 | if port is not None: |
373 | key = '%s:%s' % (host, port) | ||
374 | else: | ||
375 | key = host | ||
376 | |||
373 | if key in _ssh_cache: | 377 | if key in _ssh_cache: |
374 | return True | 378 | return True |
375 | 379 | ||
@@ -382,10 +386,13 @@ def _open_ssh(host, port): | |||
382 | 386 | ||
383 | command = ['ssh', | 387 | command = ['ssh', |
384 | '-o','ControlPath %s' % _ssh_sock(), | 388 | '-o','ControlPath %s' % _ssh_sock(), |
385 | '-p',str(port), | ||
386 | '-M', | 389 | '-M', |
387 | '-N', | 390 | '-N', |
388 | host] | 391 | host] |
392 | |||
393 | if port is not None: | ||
394 | command[3:3] = ['-p',str(port)] | ||
395 | |||
389 | try: | 396 | try: |
390 | Trace(': %s', ' '.join(command)) | 397 | Trace(': %s', ' '.join(command)) |
391 | p = subprocess.Popen(command) | 398 | p = subprocess.Popen(command) |
@@ -427,7 +434,7 @@ def _preconnect(url): | |||
427 | if ':' in host: | 434 | if ':' in host: |
428 | host, port = host.split(':') | 435 | host, port = host.split(':') |
429 | else: | 436 | else: |
430 | port = 22 | 437 | port = None |
431 | if scheme in ('ssh', 'git+ssh', 'ssh+git'): | 438 | if scheme in ('ssh', 'git+ssh', 'ssh+git'): |
432 | return _open_ssh(host, port) | 439 | return _open_ssh(host, port) |
433 | return False | 440 | return False |
@@ -435,7 +442,7 @@ def _preconnect(url): | |||
435 | m = URI_SCP.match(url) | 442 | m = URI_SCP.match(url) |
436 | if m: | 443 | if m: |
437 | host = m.group(1) | 444 | host = m.group(1) |
438 | return _open_ssh(host, 22) | 445 | return _open_ssh(host) |
439 | 446 | ||
440 | return False | 447 | return False |
441 | 448 | ||