aboutsummaryrefslogtreecommitdiff
path: root/Config.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-08-17 11:21:13 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-08-17 11:21:13 -0400
commitd7337c96cf31ef0a0ff45db399cd787c778fdd28 (patch)
tree73910f018b18fb9c679bd36e6fa30ea5d55a3b01 /Config.hs
parent29826eaa3d217a722a291b30fba5f9eda98ff518 (diff)
refactor
Diffstat (limited to 'Config.hs')
-rw-r--r--Config.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/Config.hs b/Config.hs
index d9ad80eed..4af4f1284 100644
--- a/Config.hs
+++ b/Config.hs
@@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
+
module Config where
import Common.Annex
@@ -14,6 +16,7 @@ import qualified Git.Command
import qualified Annex
import Config.Cost
import Types.Availability
+import Git.Types
type UnqualifiedConfigKey = String
data ConfigKey = ConfigKey String
@@ -41,10 +44,19 @@ reloadConfig = Annex.changeGitRepo =<< inRepo Git.Config.reRead
unsetConfig :: ConfigKey -> Annex ()
unsetConfig (ConfigKey key) = void $ inRepo $ Git.Config.unset key
+class RemoteNameable r where
+ getRemoteName :: r -> RemoteName
+
+instance RemoteNameable Git.Repo where
+ getRemoteName r = fromMaybe "" (Git.remoteName r)
+
+instance RemoteNameable RemoteName where
+ getRemoteName = id
+
{- A per-remote config setting in git config. -}
-remoteConfig :: Git.Repo -> UnqualifiedConfigKey -> ConfigKey
+remoteConfig :: RemoteNameable r => r -> UnqualifiedConfigKey -> ConfigKey
remoteConfig r key = ConfigKey $
- "remote." ++ fromMaybe "" (Git.remoteName r) ++ ".annex-" ++ key
+ "remote." ++ getRemoteName r ++ ".annex-" ++ key
{- A global annex setting in git config. -}
annexConfig :: UnqualifiedConfigKey -> ConfigKey