{- git-annex command
-
- - Copyright 2012-2014 Joey Hess <id@joeyh.name>
+ - Copyright 2012-2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
import Logs.Group
import Logs.PreferredContent
import Logs.Schedule
+import Logs.NumCopies
import Types.StandardGroups
import Types.ScheduledActivity
+import Types.NumCopies
import Remote
cmd :: Command
-cmd = command "vicfg" SectionSetup "edit git-annex's configuration"
+cmd = command "vicfg" SectionSetup "edit configuration in git-annex branch"
paramNothing (withParams seek)
seek :: CmdParams -> CommandSeek
, cfgRequiredContentMap :: M.Map UUID PreferredContentExpression
, cfgGroupPreferredContentMap :: M.Map Group PreferredContentExpression
, cfgScheduleMap :: M.Map UUID [ScheduledActivity]
+ , cfgNumCopies :: Maybe NumCopies
}
getCfg :: Annex Cfg
<*> requiredContentMapRaw
<*> groupPreferredContentMapRaw
<*> scheduleMap
+ <*> getGlobalNumCopies
setCfg :: Cfg -> Cfg -> Annex ()
setCfg curcfg newcfg = do
mapM_ (uncurry requiredContentSet) $ M.toList $ cfgRequiredContentMap diff
mapM_ (uncurry groupPreferredContentSet) $ M.toList $ cfgGroupPreferredContentMap diff
mapM_ (uncurry scheduleSet) $ M.toList $ cfgScheduleMap diff
+ maybe noop setGlobalNumCopies $ cfgNumCopies diff
{- Default config has all the keys from the input config, but with their
- default values. -}
, cfgRequiredContentMap = mapdef $ cfgRequiredContentMap curcfg
, cfgGroupPreferredContentMap = mapdef $ cfgGroupPreferredContentMap curcfg
, cfgScheduleMap = mapdef $ cfgScheduleMap curcfg
+ , cfgNumCopies = Nothing
}
where
mapdef :: forall k v. Default v => M.Map k v -> M.Map k v
, cfgRequiredContentMap = diff cfgRequiredContentMap
, cfgGroupPreferredContentMap = diff cfgGroupPreferredContentMap
, cfgScheduleMap = diff cfgScheduleMap
+ , cfgNumCopies = cfgNumCopies newcfg
}
where
diff f = M.differenceWith (\x y -> if x == y then Nothing else Just x)
, standardgroups
, requiredcontent
, schedule
+ , others
]
where
intro =
[ com $ "(for " ++ fromMaybe "" (M.lookup u descs) ++ ")"
, unwords [setting, fromUUID u, "=", val]
]
+
+ line' setting Nothing = com $ unwords [setting, "default", "="]
+ line' setting (Just val) = unwords [setting, "default", "=", val]
+
+ others =
+ [ com "Other configuration"
+ , line' "numcopies" (show . fromNumCopies <$> cfgNumCopies cfg)
+ ]
settings :: Ord v => Cfg -> M.Map UUID String -> (Cfg -> M.Map UUID v) -> [String] -> ((v, UUID) -> [String]) -> (UUID -> [String]) -> [String]
settings cfg descs = settings' cfg (M.keysSet descs)
Right l ->
let m = M.insert u l (cfgScheduleMap cfg)
in Right $ cfg { cfgScheduleMap = m }
+ | setting == "numcopies" = case readish val of
+ Nothing -> Left "parse error (expected an integer)"
+ Just n -> Right $ cfg { cfgNumCopies = Just (NumCopies n) }
| otherwise = badval "setting" setting
where
u = toUUID f
# NAME
-git-annex vicfg - edit git-annex's configuration
+git-annex vicfg - edit configuration in git-annex branch
# SYNOPSIS
# DESCRIPTION
-Opens EDITOR on a temp file containing all of git-annex's global
-configuration settings, and when it exits, stores any
-changes made back to the git-annex branch.
+Opens EDITOR on a temp file containing all of git-annex's
+configuration settings that are stored in the git-annex branch,
+and when it exits, stores any changes made back to the git-annex branch.
+
+Unlike git config settings, these configuration settings can be seen
+by all clones of the repository.
# SEE ALSO
[[git-annex]](1)
+git-config(1)
+
# AUTHOR
Joey Hess <id@joeyh.name>