Support the standard git -c name=value

This allows eg, `git-annex -c annex.rsync-options=-6 get file`

The overridden git configs are not passed on to git plumbing commands
that are run. Perhaps someone will find a need to do that, but I don't yet
and it would require storing more state to know what config settings
have been overridden and need to be passed on.
This commit is contained in:
Joey Hess 2011-07-14 16:44:23 -04:00
parent dddbc09ff0
commit 0c46cbab09
3 changed files with 15 additions and 1 deletions

View file

@ -8,12 +8,14 @@
module GitAnnex where module GitAnnex where
import System.Console.GetOpt import System.Console.GetOpt
import Control.Monad.State (liftIO)
import qualified Git import qualified Git
import CmdLine import CmdLine
import Command import Command
import Options import Options
import Utility import Utility
import Types
import Types.TrustLevel import Types.TrustLevel
import qualified Annex import qualified Annex
import qualified Remote import qualified Remote
@ -102,9 +104,11 @@ options = commonOptions ++
, Option [] ["trust"] (ReqArg (Remote.forceTrust Trusted) paramRemote) , Option [] ["trust"] (ReqArg (Remote.forceTrust Trusted) paramRemote)
"override trust setting" "override trust setting"
, Option [] ["semitrust"] (ReqArg (Remote.forceTrust SemiTrusted) paramRemote) , Option [] ["semitrust"] (ReqArg (Remote.forceTrust SemiTrusted) paramRemote)
"override trust setting back to default value" "override trust setting back to default"
, Option [] ["untrust"] (ReqArg (Remote.forceTrust UnTrusted) paramRemote) , Option [] ["untrust"] (ReqArg (Remote.forceTrust UnTrusted) paramRemote)
"override trust setting to untrusted" "override trust setting to untrusted"
, Option ['c'] ["config"] (ReqArg setgitconfig "NAME=VALUE")
"override git configuration setting"
] ]
where where
setto v = Annex.changeState $ \s -> s { Annex.toremote = Just v } setto v = Annex.changeState $ \s -> s { Annex.toremote = Just v }
@ -112,6 +116,11 @@ options = commonOptions ++
addexclude v = Annex.changeState $ \s -> s { Annex.exclude = v:Annex.exclude s } addexclude v = Annex.changeState $ \s -> s { Annex.exclude = v:Annex.exclude s }
setnumcopies v = Annex.changeState $ \s -> s {Annex.forcenumcopies = readMaybe v } setnumcopies v = Annex.changeState $ \s -> s {Annex.forcenumcopies = readMaybe v }
setkey v = Annex.changeState $ \s -> s { Annex.defaultkey = Just v } setkey v = Annex.changeState $ \s -> s { Annex.defaultkey = Just v }
setgitconfig :: String -> Annex ()
setgitconfig v = do
g <- Annex.gitRepo
g' <- liftIO $ Git.configStore g v
Annex.changeState $ \s -> s { Annex.repo = g' }
header :: String header :: String
header = "Usage: git-annex command [option ..]" header = "Usage: git-annex command [option ..]"

1
debian/changelog vendored
View file

@ -2,6 +2,7 @@ git-annex (3.20110708) UNRELEASED; urgency=low
* add: Be even more robust to avoid ever leaving the file seemingly deleted. * add: Be even more robust to avoid ever leaving the file seemingly deleted.
* Bugfix: Make add ../ work. * Bugfix: Make add ../ work.
* Support the standard git -c name=value
-- Joey Hess <joeyh@debian.org> Thu, 07 Jul 2011 21:28:49 -0400 -- Joey Hess <joeyh@debian.org> Thu, 07 Jul 2011 21:28:49 -0400

View file

@ -387,6 +387,10 @@ Many git-annex commands will stage changes for later `git commit` by you.
Specifies a key to operate on. Specifies a key to operate on.
* -c name=value
Used to override git configuration settings. May be specified multiple times.
# CONFIGURATION # CONFIGURATION
Like other git commands, git-annex is configured via `.git/config`. Like other git commands, git-annex is configured via `.git/config`.