From 8b9b90c74a0c5bc4200a85a130ec77966d059da3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 17 Jan 2020 17:09:56 -0400 Subject: [PATCH] bugfixes getRemoteConfigPassedThrough was never returning anything, Typeable prevented the type checker from noticing a dumb mistake. parseRemoteConfig was not adding Accepted values as PassedThrough --- Annex/SpecialRemote/Config.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Annex/SpecialRemote/Config.hs b/Annex/SpecialRemote/Config.hs index eb955d84a1..117963fb3c 100644 --- a/Annex/SpecialRemote/Config.hs +++ b/Annex/SpecialRemote/Config.hs @@ -172,7 +172,7 @@ getRemoteConfigValue f m = case M.lookup f m of {- Gets all fields that remoteConfigRestPassthrough matched. -} getRemoteConfigPassedThrough :: ParsedRemoteConfig -> M.Map RemoteConfigField String -getRemoteConfigPassedThrough = M.mapMaybe $ \v -> +getRemoteConfigPassedThrough = M.mapMaybe $ \(RemoteConfigValue v) -> case cast v of Just (PassedThrough s) -> Just s Nothing -> Nothing @@ -181,15 +181,16 @@ newtype PassedThrough = PassedThrough String parseRemoteConfig :: RemoteConfig -> RemoteConfigParser -> Either String ParsedRemoteConfig parseRemoteConfig c rpc = - go [] (M.filterWithKey notaccepted c) (remoteConfigFieldParsers rpc ++ commonFieldParsers) + go [] c (remoteConfigFieldParsers rpc ++ commonFieldParsers) where go l c' [] = let (passover, leftovers) = partition (remoteConfigRestPassthrough rpc . fst) (M.toList c') - in if not (null leftovers) + leftovers' = filter (notaccepted . fst) leftovers + in if not (null leftovers') then Left $ "Unexpected parameters: " ++ - unwords (map (fromProposedAccepted . fst) leftovers) + unwords (map (fromProposedAccepted . fst) leftovers') else Right $ M.fromList $ l ++ map (uncurry passthrough) passover go l c' ((f, p):rest) = do @@ -200,8 +201,8 @@ parseRemoteConfig c rpc = passthrough f v = (f, RemoteConfigValue (PassedThrough (fromProposedAccepted v))) - notaccepted (Proposed _) _ = True - notaccepted (Accepted _) _ = False + notaccepted (Proposed _) = True + notaccepted (Accepted _) = False optionalStringParser :: RemoteConfigField -> RemoteConfigFieldParser optionalStringParser f = (f, p)