fixed behavior when multiple insteadOf configs are provided for the same url base
Consider this git config --list case: url.git+ssh://git@example.com/.insteadOf=gl url.git+ssh://git@example.com/.insteadOf=shared Since config is stored in a Map, only the last of the values for this key was stored and available for use by the insteadOf code. But that is wrong; git allows either "gl" or "shared" to be used in an url and the insteadOf value to be substituted in. To support this, it seems best to keep the existing config map as-is, and add a second map that accumulates a list of multiple values for config keys. This new fullconfig map can be used in the rare places where multiple values for a key make sense, without needing to complicate everything else. Haskell's laziness and data sharing keep the overhead of adding this second map low.
This commit is contained in:
parent
3dffcf9ccb
commit
5287d1dc3f
4 changed files with 17 additions and 4 deletions
|
@ -115,7 +115,6 @@ remoteNamedFromKey k = remoteNamed basename
|
|||
fromRemoteLocation :: String -> Repo -> IO Repo
|
||||
fromRemoteLocation s repo = gen $ calcloc s
|
||||
where
|
||||
filterconfig f = filter f $ M.toList $ config repo
|
||||
gen v
|
||||
| scpstyle v = fromUrl $ scptourl v
|
||||
| isURI v = fromUrl v
|
||||
|
@ -133,6 +132,10 @@ fromRemoteLocation s repo = gen $ calcloc s
|
|||
startswith prefix k &&
|
||||
endswith suffix k &&
|
||||
startswith v l
|
||||
filterconfig f = filter f $
|
||||
concatMap splitconfigs $
|
||||
M.toList $ fullconfig repo
|
||||
splitconfigs (k, vs) = map (\v -> (k, v)) vs
|
||||
(prefix, suffix) = ("url." , ".insteadof")
|
||||
-- git remotes can be written scp style -- [user@]host:dir
|
||||
scpstyle v = ":" `isInfixOf` v && not ("//" `isInfixOf` v)
|
||||
|
@ -210,6 +213,7 @@ newFrom l =
|
|||
Repo {
|
||||
location = l,
|
||||
config = M.empty,
|
||||
fullconfig = M.empty,
|
||||
remotes = [],
|
||||
remoteName = Nothing
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue