summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-15 19:03:25 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-15 19:03:25 -0400
commit80a0be5116ada2c718fa6db0a90100d24660beec (patch)
treeb9981e773f3e4c2410f26df621cc4bbf7d93b243
parent7d05ca1d6d01f7e9f8b2acdebac2b656e178a32c (diff)
further insteadOf fix
-rw-r--r--Git.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/Git.hs b/Git.hs
index 3ff42d28f..3f3f74632 100644
--- a/Git.hs
+++ b/Git.hs
@@ -521,16 +521,17 @@ genRemote s repo = gen $ calcloc s
-- insteadof config can rewrite remote location
calcloc l
| null insteadofs = l
- | otherwise = replacement ++ drop (length replacement) l
+ | otherwise = replacement ++ drop (length bestvalue) l
where
- replacement = drop (length "url.") $
+ replacement = drop (length prefix) $
take (length bestkey - length suffix) bestkey
- bestkey = fst $ maximumBy longestvalue insteadofs
+ (bestkey, bestvalue) = maximumBy longestvalue insteadofs
longestvalue (_, a) (_, b) = compare b a
insteadofs = filterconfig $ \(k, v) ->
+ startswith prefix k &&
endswith suffix k &&
startswith v l
- suffix = ".insteadof"
+ (prefix, suffix) = ("url." , ".insteadof")
-- git remotes can be written scp style -- [user@]host:dir
scpstyle v = ":" `isInfixOf` v && not ("//" `isInfixOf` v)
scptourl v = "ssh://" ++ host ++ slash dir