summaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-05 15:31:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-05 15:31:46 -0400
commitaad1372880ba32f1161a0d05422008cba38bb412 (patch)
tree3ff855af958b091e9d31f6b94438a3b9c4f52550 /Annex.hs
parentacde7a1736fdee58be0af0773da6e2d9e0c2d220 (diff)
move repoConfig out of Remotes
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Annex.hs b/Annex.hs
index 62e7e023d..dd3362b29 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -16,10 +16,12 @@ module Annex (
gitRepo,
queue,
queueRun,
- setConfig
+ setConfig,
+ repoConfig
) where
import Control.Monad.State
+import Data.Maybe
import qualified GitRepo as Git
import qualified GitQueue
@@ -115,3 +117,14 @@ setConfig k value = do
-- re-read git config and update the repo's state
g' <- liftIO $ Git.configRead g
Annex.changeState $ \s -> s { Annex.repo = g' }
+
+{- Looks up a per-remote config option in git config.
+ - Failing that, tries looking for a global config option. -}
+repoConfig :: Git.Repo -> String -> String -> Annex String
+repoConfig r key def = do
+ g <- Annex.gitRepo
+ let def' = Git.configGet g global def
+ return $ Git.configGet g local def'
+ where
+ local = "remote." ++ fromMaybe "" (Git.repoRemoteName r) ++ ".annex-" ++ key
+ global = "annex." ++ key