summaryrefslogtreecommitdiff
path: root/Git.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Git.hs')
-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