, checkignorehandle :: Maybe (Maybe CheckIgnoreHandle)
, forcebackend :: Maybe String
, globalnumcopies :: Maybe NumCopies
+ , globalconfig :: Maybe (M.Map String String)
, forcenumcopies :: Maybe NumCopies
, limit :: ExpandableMatcher Annex
, uuidmap :: Maybe UUIDMap
, checkignorehandle = Nothing
, forcebackend = Nothing
, globalnumcopies = Nothing
+ , globalconfig = Nothing
, forcenumcopies = Nothing
, limit = BuildingMatcher []
, uuidmap = Nothing
getRef :: Ref -> FilePath -> Annex String
getRef ref file = withIndex $ decodeBS <$> catFile ref file
-{- Applies a function to modifiy the content of a file.
+{- Applies a function to modify the content of a file.
-
- Note that this does not cause the branch to be merged, it only
- modifes the current content of the file on the branch.
* Remove -j short option for --json-progress; that option was already
taken for --json.
* vicfg: Include the numcopies configuation.
+ * config: New command for storing configuration in the git-annex branch.
-- Joey Hess <id@joeyh.name> Fri, 06 Jan 2017 15:22:06 -0400
import qualified Command.Required
import qualified Command.Schedule
import qualified Command.Ungroup
+import qualified Command.Config
import qualified Command.Vicfg
import qualified Command.Sync
import qualified Command.Mirror
, Command.Required.cmd
, Command.Schedule.cmd
, Command.Ungroup.cmd
+ , Command.Config.cmd
, Command.Vicfg.cmd
, Command.LookupKey.cmd
, Command.CalcKey.cmd
--- /dev/null
+{- git-annex command
+ -
+ - Copyright 2017 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Command.Config where
+
+import Command
+import Logs.Config
+
+cmd :: Command
+cmd = command "config" SectionSetup "configuration stored in git-annex branch"
+ paramNothing (seek <$$> optParser)
+
+data Action
+ = SetConfig ConfigName ConfigValue
+ | GetConfig ConfigName
+ | UnsetConfig ConfigName
+
+type Name = String
+type Value = String
+
+optParser :: CmdParamsDesc -> Parser Action
+optParser _ = setconfig <|> getconfig <|> unsetconfig
+ where
+ setconfig = SetConfig
+ <$> strOption
+ ( long "set"
+ <> help "set configuration"
+ <> metavar paramName
+ )
+ <*> strArgument
+ ( metavar paramValue
+ )
+ getconfig = GetConfig <$> strOption
+ ( long "get"
+ <> help "get configuration"
+ <> metavar paramName
+ )
+ unsetconfig = UnsetConfig <$> strOption
+ ( long "unset"
+ <> help "unset configuration"
+ <> metavar paramName
+ )
+
+seek :: Action -> CommandSeek
+seek (SetConfig name val) = commandAction $ do
+ showStart name val
+ next $ next $ do
+ setGlobalConfig name val
+ return True
+seek (UnsetConfig name) = commandAction $ do
+ showStart name "unset"
+ next $ next $ do
+ unsetGlobalConfig name
+ return True
+seek (GetConfig name) = commandAction $ do
+ mv <- getGlobalConfig name
+ case mv of
+ Nothing -> stop
+ Just v -> do
+ liftIO $ putStrLn v
+ stop
numcopiesLog :: FilePath
numcopiesLog = "numcopies.log"
+configLog :: FilePath
+configLog = "config.log"
+
remoteLog :: FilePath
remoteLog = "remote.log"
--- /dev/null
+# NAME
+
+git-annex config - configuration stored in git-annex branch
+
+# SYNOPSIS
+
+git annex config --set name value
+
+git annex config --get name
+
+git annex config --unset name
+
+# DESCRIPTION
+
+Set or get configuration settings stored in the git-annex branch.
+
+Unlike `git config` settings, these settings can be seen
+in all clones of the repository, once they have gotten their
+git-annex branches in sync.
+
+# SUPPORTED SETTINGS
+
+git-annex does not check the git-annex branch for all settings.
+Only a few make sense to be able to set such that all clones of a
+repository see the setting, and so git-annex only looks for these:
+
+These settings can be overridden on a per-repository basis using
+`git config`:
+
+None yet!
+
+# EXAMPLE
+
+Suppose you want to prevent git annex sync from committing changes
+to files, so a manual git commit workflow is used in all clones of the
+repository. Then run:
+
+ git annex config --set annex.autocommit false
+
+If you change your mind, you can get back to the default behavior:
+
+ git annex config --unset annex.autocommit
+
+# SEE ALSO
+
+[[git-annex]](1)
+
+git-config(1)
+
+[[git-annex-vicfg]](1)
+
+# AUTHOR
+
+Joey Hess <id@joeyh.name>
+
+Warning: Automatically converted into a man page by mdwn2man. Edit with care.
* `--commit`, `--no-commit`
- A commit is done by default. Use --no-commit to avoid committing local changes.
+ A commit is done by default (unless annex.autocommit is set to false).
+
+ Use --no-commit to avoid committing local changes.
* `--message=msg`
See [[git-annex-schedule]](1) for details.
+* `config`
+
+ Get and set other configuration stored in git-annex branch.
+
+ See [[git-annex-config]](1) for details.
+
* `vicfg`
Opens EDITOR on a temp file containing most of the above configuration
Set to false to prevent the git-annex assistant and git-annex sync
from automatically committing changes to files in the repository.
+ To configure the behavior in all repositories, this can be set in
+ [[git-annex-config]].
+
* `annex.startupscan`
Set to false to prevent the git-annex assistant from scanning the
The file format is simply a timestamp followed by a number.
+## `config.log`
+
+Records global configuration settings, which can be overridden by values
+in `.git/config`.
+
+The file format is a timestamp, followed by the name of the configuration,
+followed by the value. For example:
+
+ 1317929189.157237s annex.autocommit false
+
## `remote.log`
Holds persistent configuration settings for [[special_remotes]] such as
--- /dev/null
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2017-01-30T18:13:42Z"
+ content="""
+This could be put in the git-annex branch similarly to the `git annex
+numcopies` configuration so all clones see it.
+
+As well as --no-commit, --content is the other option that I think
+might make sense to have a clone-wide setting for. sync's --no-pull and
+--no-push seem much less likely to need such a setting.
+
+I've been leaning toward eventually turning sync --content on by default,
+and such a clone-wide configuration would be useful to let users get back
+the current behavior.
+
+Hmm, this could be generalized all the way to having a file in the
+git-annex branch that stores default settings for `annex.*` configs.
+But then git-annex would have to pull that file out of the git-annex branch
+every time it's run, which would slow down commands that get run a lot in
+succession. So that's a generalization too far.
+
+Still, looking through the configs, I can see some other things
+that it would similarly make sense to sometimes want to set clone-wide,
+including: annex.genmetadata, annex.used-refspec, annex.diskreserve,
+annex.addsmallfiles.
+
+So, we have some configs that are each only used by a few commands,
+that make sense to be allowed to be set clone-wide. We can make the file
+in the git-annex branch be only read by commands that look at those
+configs, and can consider when implementing each whether it would slow
+down any command too much to have it need to read the git-annex branch
+file.
+
+I've added a `git annex config` command that can set such clone-wide
+configurations. I have not yet made git annex sync look at it for
+annex.autocommit.
+"""]]