diff options
Diffstat (limited to 'Annex.hs')
-rw-r--r-- | Annex.hs | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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 |