mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Honor url.insteadOf when setting up SSH control master connection
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>
This commit is contained in:
parent
aa4982e4c9
commit
b6ea3bfcc3
@ -442,8 +442,30 @@ class Remote(object):
|
|||||||
self._Get('fetch', all=True))
|
self._Get('fetch', all=True))
|
||||||
self._review_protocol = None
|
self._review_protocol = None
|
||||||
|
|
||||||
|
def _InsteadOf(self):
|
||||||
|
globCfg = GitConfig.ForUser()
|
||||||
|
urlList = globCfg.GetSubSections('url')
|
||||||
|
longest = ""
|
||||||
|
longestUrl = ""
|
||||||
|
|
||||||
|
for url in urlList:
|
||||||
|
key = "url." + url + ".insteadOf"
|
||||||
|
insteadOfList = globCfg.GetString(key, all=True)
|
||||||
|
|
||||||
|
for insteadOf in insteadOfList:
|
||||||
|
if self.url.startswith(insteadOf) \
|
||||||
|
and len(insteadOf) > len(longest):
|
||||||
|
longest = insteadOf
|
||||||
|
longestUrl = url
|
||||||
|
|
||||||
|
if len(longest) == 0:
|
||||||
|
return self.url
|
||||||
|
|
||||||
|
return self.url.replace(longest, longestUrl, 1)
|
||||||
|
|
||||||
def PreConnectFetch(self):
|
def PreConnectFetch(self):
|
||||||
return _preconnect(self.url)
|
connectionUrl = self._InsteadOf()
|
||||||
|
return _preconnect(connectionUrl)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ReviewProtocol(self):
|
def ReviewProtocol(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user