From 9c7b3dce9e8f964ed60dd45bca580a46ff8a5ed5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 28 Oct 2010 12:15:21 -0400 Subject: [PATCH] tweaks --- GitRepo.hs | 18 +++++++++++------- Remotes.hs | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/GitRepo.hs b/GitRepo.hs index 229b76847f..0e87c9526d 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -24,6 +24,7 @@ module GitRepo ( configGet, configMap, configRead, + configTrue, run, pipeRead, attributes, @@ -47,6 +48,7 @@ import Data.String.Utils import Data.Map as Map hiding (map, split) import Network.URI import Maybe +import Char import Utility @@ -127,13 +129,11 @@ assertssh repo action = then action else error $ "unsupported url " ++ (show $ url repo) bare :: Repo -> Bool -bare repo = - if (member b (config repo)) - then ("true" == fromJust (Map.lookup b (config repo))) - else error $ "it is not known if git repo " ++ (repoDescribe repo) ++ +bare repo = case Map.lookup "core.bare" $ config repo of + Just v -> configTrue v + Nothing -> error $ "it is not known if git repo " ++ + (repoDescribe repo) ++ " is a bare repository; config not read" - where - b = "core.bare" {- Path to a repository's gitattributes file. -} attributes :: Repo -> String @@ -173,7 +173,7 @@ relative repo file = assertLocal repo $ drop (length absrepo) absfile {- Hostname of an URL repo. (May include a username and/or port too.) -} urlHost :: Repo -> String urlHost repo = assertUrl repo $ - (uriUserInfo a) ++ (uriRegName a) ++ (uriPort a) + uriUserInfo a ++ uriRegName a ++ uriPort a where a = fromJust $ uriAuthority $ url repo @@ -235,6 +235,10 @@ configRead repo = let r = repo { config = configParse val } return r { remotes = configRemotes r } +{- Checks if a string fron git config is a true value. -} +configTrue :: String -> Bool +configTrue s = map toLower s == "true" + {- Calculates a list of a repo's configured remotes, by parsing its config. -} configRemotes :: Repo -> [Repo] configRemotes repo = map construct remotes diff --git a/Remotes.hs b/Remotes.hs index 665de38ae5..bee98a6f3d 100644 --- a/Remotes.hs +++ b/Remotes.hs @@ -139,10 +139,10 @@ repoNotIgnored r = do let name = if (not $ null fromName) then fromName else toName if (not $ null name) then return $ match name - else return $ notignored g + else return $ not $ ignored g where match name = name == Git.repoRemoteName r - notignored g = "true" /= config g + ignored g = Git.configTrue $ config g config g = Git.configGet g configkey "" configkey = "remote." ++ (Git.repoRemoteName r) ++ ".annex-ignore"