summaryrefslogtreecommitdiffstats
path: root/git_config.py
diff options
context:
space:
mode:
authorUlrik Sjolin <ulrik.sjolin@gmail.com>2010-01-03 18:20:17 +0100
committerShawn O. Pearce <sop@google.com>2010-01-04 05:38:39 -0800
commitb6ea3bfcc398417b91a4fa5a486324f4d904b022 (patch)
treedc6bc95c3b05ab032a343bbeeee5ac62e917b5da /git_config.py
parentaa4982e4c937d9be0f69c250692839eb98a184e8 (diff)
downloadgit-repo-b6ea3bfcc398417b91a4fa5a486324f4d904b022.tar.gz
Honor url.insteadOf when setting up SSH control master connectionv1.6.8.10
Repo can now properly handle url.insteadOf sections in the user's ~/.gitconfig file. This means that a user can now enjoy the master-ssh functionality even if he/she uses insteadOf's in ~/.gitconfig to rewrite git:// URLs to ssh:// style URLs. Change-Id: Ic0f04a9c57206a7b89eb0f10bf188c4c483debe3 Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'git_config.py')
-rw-r--r--git_config.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/git_config.py b/git_config.py
index e1e20463..45a2d257 100644
--- a/git_config.py
+++ b/git_config.py
@@ -442,8 +442,30 @@ class Remote(object):
442 self._Get('fetch', all=True)) 442 self._Get('fetch', all=True))
443 self._review_protocol = None 443 self._review_protocol = None
444 444
445 def _InsteadOf(self):
446 globCfg = GitConfig.ForUser()
447 urlList = globCfg.GetSubSections('url')
448 longest = ""
449 longestUrl = ""
450
451 for url in urlList:
452 key = "url." + url + ".insteadOf"
453 insteadOfList = globCfg.GetString(key, all=True)
454
455 for insteadOf in insteadOfList:
456 if self.url.startswith(insteadOf) \
457 and len(insteadOf) > len(longest):
458 longest = insteadOf
459 longestUrl = url
460
461 if len(longest) == 0:
462 return self.url
463
464 return self.url.replace(longest, longestUrl, 1)
465
445 def PreConnectFetch(self): 466 def PreConnectFetch(self):
446 return _preconnect(self.url) 467 connectionUrl = self._InsteadOf()
468 return _preconnect(connectionUrl)
447 469
448 @property 470 @property
449 def ReviewProtocol(self): 471 def ReviewProtocol(self):