summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-05-05 20:15:32 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-05-05 20:16:56 -0400
commitf7d8982672fd330a466c2cb22f34388e7cc429c0 (patch)
treeb5739058cc2cb04fa4a119df2cecf449d4846c03
parent657d09d49990af85c1a91b1154a195a30438477c (diff)
Fix use of several config settings
annex.ssh-options, annex.rsync-options, annex.bup-split-options. And adjust types to avoid the bugs that broke several config settings recently. Now "annex." prefixing is enforced at the type level.
-rw-r--r--Annex/Content.hs4
-rw-r--r--Annex/Queue.hs2
-rw-r--r--Annex/Ssh.hs2
-rw-r--r--Annex/UUID.hs14
-rw-r--r--Annex/Version.hs4
-rw-r--r--Backend.hs2
-rw-r--r--Command/Unused.hs4
-rw-r--r--Config.hs43
-rw-r--r--Remote/Hook.hs4
-rw-r--r--debian/changelog3
10 files changed, 49 insertions, 33 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index b5754e15b..2142d1f09 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -304,12 +304,12 @@ saveState oneshot = doSideAction $ do
( Annex.Branch.commit "update" , Annex.Branch.stage)
where
alwayscommit = fromMaybe True . Git.configTrue
- <$> getConfig "annex.alwayscommit" ""
+ <$> getConfig (annexConfig "alwayscommit") ""
{- Downloads content from any of a list of urls. -}
downloadUrl :: [Url.URLString] -> FilePath -> Annex Bool
downloadUrl urls file = do
- o <- map Param . words <$> getConfig "annex.web-options" ""
+ o <- map Param . words <$> getConfig (annexConfig "web-options") ""
headers <- getHttpHeaders
liftIO $ anyM (\u -> Url.download u headers o file) urls
diff --git a/Annex/Queue.hs b/Annex/Queue.hs
index 728e29645..24575e906 100644
--- a/Annex/Queue.hs
+++ b/Annex/Queue.hs
@@ -46,7 +46,7 @@ new = do
store q
return q
where
- queuesize = readish <$> getConfig "annex.queuesize" ""
+ queuesize = readish <$> getConfig (annexConfig "queuesize") ""
store :: Git.Queue.Queue -> Annex ()
store q = changeState $ \s -> s { repoqueue = Just q }
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index 6a230312a..f0824b119 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -48,7 +48,7 @@ sshInfo (host, port) = ifM caching
where
caching = fromMaybe SysConfig.sshconnectioncaching
. Git.configTrue
- <$> getConfig "annex.sshcaching" ""
+ <$> getConfig (annexConfig "sshcaching") ""
cacheParams :: FilePath -> [CommandParam]
cacheParams socketfile =
diff --git a/Annex/UUID.hs b/Annex/UUID.hs
index 5459cc7fe..517840fba 100644
--- a/Annex/UUID.hs
+++ b/Annex/UUID.hs
@@ -23,12 +23,11 @@ module Annex.UUID (
import Common.Annex
import qualified Git
import qualified Git.Config
-import qualified Git.Command
import qualified Build.SysConfig as SysConfig
import Config
-configkey :: String
-configkey = "annex.uuid"
+configkey :: ConfigKey
+configkey = annexConfig "uuid"
{- Generates a UUID. There is a library for this, but it's not packaged,
- so use the command line tool. -}
@@ -64,16 +63,17 @@ getRepoUUID r = do
cachekey = remoteConfig r "uuid"
removeRepoUUID :: Annex ()
-removeRepoUUID = inRepo $ Git.Command.run "config"
- [Param "--unset", Param configkey]
+removeRepoUUID = unsetConfig configkey
getUncachedUUID :: Git.Repo -> UUID
-getUncachedUUID = toUUID . Git.Config.get configkey ""
+getUncachedUUID = toUUID . Git.Config.get key ""
+ where
+ (ConfigKey key) = configkey
{- Make sure that the repo has an annex.uuid setting. -}
prepUUID :: Annex ()
prepUUID = whenM ((==) NoUUID <$> getUUID) $
storeUUID configkey =<< liftIO genUUID
-storeUUID :: String -> UUID -> Annex ()
+storeUUID :: ConfigKey -> UUID -> Annex ()
storeUUID configfield = setConfig configfield . fromUUID
diff --git a/Annex/Version.hs b/Annex/Version.hs
index a1d040244..7c909ae05 100644
--- a/Annex/Version.hs
+++ b/Annex/Version.hs
@@ -21,8 +21,8 @@ supportedVersions = [defaultVersion]
upgradableVersions :: [Version]
upgradableVersions = ["0", "1", "2"]
-versionField :: String
-versionField = "annex.version"
+versionField :: ConfigKey
+versionField = annexConfig "version"
getVersion :: Annex (Maybe Version)
getVersion = handle <$> getConfig versionField ""
diff --git a/Backend.hs b/Backend.hs
index 19562205c..8071b9b83 100644
--- a/Backend.hs
+++ b/Backend.hs
@@ -46,7 +46,7 @@ orderedList = do
l' <- (lookupBackendName name :) <$> standard
Annex.changeState $ \s -> s { Annex.backends = l' }
return l'
- standard = parseBackendList <$> getConfig "annex.backends" ""
+ standard = parseBackendList <$> getConfig (annexConfig "backends") ""
parseBackendList [] = list
parseBackendList s = map lookupBackendName $ words s
diff --git a/Command/Unused.hs b/Command/Unused.hs
index 6b319ee72..f5ee452a8 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -183,10 +183,10 @@ exclude smaller larger = S.toList $ remove larger $ S.fromList smaller
-}
bloomCapacity :: Annex Int
bloomCapacity = fromMaybe 500000 . readish
- <$> getConfig "annex.bloomcapacity" ""
+ <$> getConfig (annexConfig "bloomcapacity") ""
bloomAccuracy :: Annex Int
bloomAccuracy = fromMaybe 1000 . readish
- <$> getConfig "annex.bloomaccuracy" ""
+ <$> getConfig (annexConfig "bloomaccuracy") ""
bloomBitsHashes :: Annex (Int, Int)
bloomBitsHashes = do
capacity <- bloomCapacity
diff --git a/Config.hs b/Config.hs
index 3feb246e5..5f1ac8bb2 100644
--- a/Config.hs
+++ b/Config.hs
@@ -1,6 +1,6 @@
{- Git configuration
-
- - Copyright 2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2011-2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -14,29 +14,40 @@ import qualified Git.Command
import qualified Annex
import Utility.DataUnits
-type ConfigKey = String
+type UnqualifiedConfigKey = String
+data ConfigKey = ConfigKey String
{- Changes a git config setting in both internal state and .git/config -}
setConfig :: ConfigKey -> String -> Annex ()
-setConfig k value = do
- inRepo $ Git.Command.run "config" [Param k, Param value]
+setConfig (ConfigKey key) value = do
+ inRepo $ Git.Command.run "config" [Param key, Param value]
-- re-read git config and update the repo's state
newg <- inRepo Git.Config.read
Annex.changeState $ \s -> s { Annex.repo = newg }
-{- Looks up a git config setting in git config. -}
+{- Unsets a git config setting. (Leaves it in state currently.) -}
+unsetConfig :: ConfigKey -> Annex ()
+unsetConfig (ConfigKey key) = inRepo $ Git.Command.run "config"
+ [Param "--unset", Param key]
+
+{- Looks up a setting in git config. -}
getConfig :: ConfigKey -> String -> Annex String
-getConfig key def = fromRepo $ Git.Config.get key def
+getConfig (ConfigKey key) def = fromRepo $ Git.Config.get key def
{- Looks up a per-remote config setting in git config.
- Failing that, tries looking for a global config option. -}
-getRemoteConfig :: Git.Repo -> ConfigKey -> String -> Annex String
-getRemoteConfig r key def =
- getConfig (remoteConfig r key) =<< getConfig key def
+getRemoteConfig :: Git.Repo -> UnqualifiedConfigKey -> String -> Annex String
+getRemoteConfig r key def =
+ getConfig (remoteConfig r key) =<< getConfig (annexConfig key) def
{- A per-remote config setting in git config. -}
-remoteConfig :: Git.Repo -> ConfigKey -> String
-remoteConfig r key = "remote." ++ fromMaybe "" (Git.remoteName r) ++ ".annex-" ++ key
+remoteConfig :: Git.Repo -> UnqualifiedConfigKey -> ConfigKey
+remoteConfig r key = ConfigKey $
+ "remote." ++ fromMaybe "" (Git.remoteName r) ++ ".annex-" ++ key
+
+{- A global annex setting in git config. -}
+annexConfig :: UnqualifiedConfigKey -> ConfigKey
+annexConfig key = ConfigKey $ "annex." ++ key
{- Calculates cost for a remote. Either the default, or as configured
- by remote.<name>.annex-cost, or if remote.<name>.annex-cost-command
@@ -83,17 +94,19 @@ getNumCopies v = perhaps (use v) =<< Annex.getState Annex.forcenumcopies
where
use (Just n) = return n
use Nothing = perhaps (return 1) =<<
- readish <$> getConfig "annex.numcopies" "1"
+ readish <$> getConfig (annexConfig "numcopies") "1"
perhaps fallback = maybe fallback (return . id)
{- Gets the trust level set for a remote in git config. -}
getTrustLevel :: Git.Repo -> Annex (Maybe String)
-getTrustLevel r = fromRepo $ Git.Config.getMaybe $ remoteConfig r "trustlevel"
+getTrustLevel r = fromRepo $ Git.Config.getMaybe key
+ where
+ (ConfigKey key) = remoteConfig r "trustlevel"
{- Gets annex.diskreserve setting. -}
getDiskReserve :: Annex Integer
getDiskReserve = fromMaybe megabyte . readSize dataUnits
- <$> getConfig "annex.diskreserve" ""
+ <$> getConfig (annexConfig "diskreserve") ""
where
megabyte = 1000000
@@ -101,7 +114,7 @@ getDiskReserve = fromMaybe megabyte . readSize dataUnits
- splitting it into lines. -}
getHttpHeaders :: Annex [String]
getHttpHeaders = do
- cmd <- getConfig "annex.http-headers-command" ""
+ cmd <- getConfig (annexConfig "http-headers-command") ""
if (null cmd)
then fromRepo $ Git.Config.getList "annex.http-headers"
else lines . snd <$> liftIO (pipeFrom "sh" ["-c", cmd])
diff --git a/Remote/Hook.hs b/Remote/Hook.hs
index 1c87823ca..dcac9da88 100644
--- a/Remote/Hook.hs
+++ b/Remote/Hook.hs
@@ -74,14 +74,14 @@ hookEnv k f = Just $ fileenv f ++ keyenv
lookupHook :: String -> String -> Annex (Maybe String)
lookupHook hooktype hook =do
- command <- getConfig hookname ""
+ command <- getConfig (annexConfig hookname) ""
if null command
then do
warning $ "missing configuration for " ++ hookname
return Nothing
else return $ Just command
where
- hookname = "annex." ++ hooktype ++ "-" ++ hook ++ "-hook"
+ hookname = hooktype ++ "-" ++ hook ++ "-hook"
runHook :: String -> String -> Key -> Maybe FilePath -> Annex Bool -> Annex Bool
runHook hooktype hook k f a = maybe (return False) run =<< lookupHook hooktype hook
diff --git a/debian/changelog b/debian/changelog
index b419b4622..049531dad 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,9 @@ git-annex (3.20120431) UNRELEASED; urgency=low
* dropunused: Allow specifying ranges to drop.
* addunused: New command, the opposite of dropunused, it relinks unused
content into the git repository.
+ * Fix use of several config settings annex.ssh-options,
+ annex.rsync-options, annex.bup-split-options. (And adjust types to avoid
+ the bugs that broke several config settings.)
-- Joey Hess <joeyh@debian.org> Wed, 02 May 2012 13:06:18 -0400