summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-05 13:38:37 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-05 13:38:37 -0400
commite96c613c026c2d0bd6cce7210b058533d3ce972c (patch)
treea44c598f4b1047593f4c856fdd26e9ac8400556d
parent70db4ebffa5a66ac97791d6780cb203ad6ac642f (diff)
pass -c option on to all git commands run
The -c option now not only modifies the git configuration seen by git-annex, but it is passed along to every git command git-annex runs. This was easy to plumb through because gitCommandLine is already used to construct every git command line, to add --git-dir and --work-tree
-rw-r--r--Git/Command.hs3
-rw-r--r--Git/Construct.hs1
-rw-r--r--Git/Types.hs3
-rw-r--r--GitAnnex/Options.hs7
-rw-r--r--debian/changelog2
5 files changed, 13 insertions, 3 deletions
diff --git a/Git/Command.hs b/Git/Command.hs
index 8b027d2c3..adcc53bcd 100644
--- a/Git/Command.hs
+++ b/Git/Command.hs
@@ -21,7 +21,8 @@ import Git.FilePath
{- Constructs a git command line operating on the specified repo. -}
gitCommandLine :: [CommandParam] -> Repo -> [CommandParam]
-gitCommandLine params Repo { location = l@(Local _ _ ) } = setdir : settree ++ params
+gitCommandLine params r@(Repo { location = l@(Local _ _ ) }) =
+ setdir : settree ++ gitGlobalOpts r ++ params
where
setdir = Param $ "--git-dir=" ++ gitpath (gitdir l)
settree = case worktree l of
diff --git a/Git/Construct.hs b/Git/Construct.hs
index cd998591e..71a13f49f 100644
--- a/Git/Construct.hs
+++ b/Git/Construct.hs
@@ -230,6 +230,7 @@ newFrom l = return Repo
, remotes = []
, remoteName = Nothing
, gitEnv = Nothing
+ , gitGlobalOpts = []
}
diff --git a/Git/Types.hs b/Git/Types.hs
index abfb99f9f..2a33fb27d 100644
--- a/Git/Types.hs
+++ b/Git/Types.hs
@@ -10,6 +10,7 @@ module Git.Types where
import Network.URI
import qualified Data.Map as M
import System.Posix.Types
+import Utility.SafeCommand
{- Support repositories on local disk, and repositories accessed via an URL.
-
@@ -38,6 +39,8 @@ data Repo = Repo
, remoteName :: Maybe String
-- alternate environment to use when running git commands
, gitEnv :: Maybe [(String, String)]
+ -- global options to pass to git when running git commands
+ , gitGlobalOpts :: [CommandParam]
} deriving (Show, Eq)
{- A git ref. Can be a sha1, or a branch or tag name. -}
diff --git a/GitAnnex/Options.hs b/GitAnnex/Options.hs
index 7f4cb60c2..88fad948a 100644
--- a/GitAnnex/Options.hs
+++ b/GitAnnex/Options.hs
@@ -11,6 +11,7 @@ import System.Console.GetOpt
import Common.Annex
import qualified Git.Config
+import Git.Types
import Command
import Types.TrustLevel
import qualified Annex
@@ -59,12 +60,14 @@ options = Option.common ++
"Trust Amazon Glacier inventory"
] ++ Option.matcher
where
+ trustArg t = ReqArg (Remote.forceTrust t) paramRemote
setnumcopies v = maybe noop
(\n -> Annex.changeState $ \s -> s { Annex.forcenumcopies = Just n })
(readish v)
setuseragent v = Annex.changeState $ \s -> s { Annex.useragent = Just v }
- setgitconfig v = Annex.changeGitRepo =<< inRepo (Git.Config.store v)
- trustArg t = ReqArg (Remote.forceTrust t) paramRemote
+ setgitconfig v = inRepo (Git.Config.store v)
+ >>= pure . (\r -> r { gitGlobalOpts = gitGlobalOpts r ++ [Param "-c", Param v] })
+ >>= Annex.changeGitRepo
keyOptions :: [Option]
keyOptions =
diff --git a/debian/changelog b/debian/changelog
index f8d49df09..3d5e9a394 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,8 @@ git-annex (4.20131102) UNRELEASED; urgency=low
* Fix zombie process that occurred when switching between repository
views in the webapp.
* map: Work when there are gcrypt remotes.
+ * The -c option now not only modifies the git configuration seen by
+ git-annex, but it is passed along to every git command git-annex runs.
-- Joey Hess <joeyh@debian.org> Sat, 02 Nov 2013 14:54:36 -0400