changeGitRepo,
adjustGitRepo,
addGitConfigOverride,
+ getGitConfigOverrides,
getRemoteGitConfig,
withCurrentState,
changeDirectory,
, repoadjustment :: (Git.Repo -> IO Git.Repo)
, gitconfig :: GitConfig
, gitconfigadjustment :: (GitConfig -> GitConfig)
+ , gitconfigoverride :: [String]
, gitremotes :: Maybe [Git.Repo]
, backend :: Maybe (BackendA Annex)
, remotes :: [Types.Remote.RemoteA Annex]
, repoadjustment = return
, gitconfig = c
, gitconfigadjustment = id
+ , gitconfigoverride = []
, gitremotes = Nothing
, backend = Nothing
, remotes = []
changeGitRepo =<< gitRepo
{- Adds git config setting, like "foo=bar". It will be passed with -c
- - to git processes. The config setting is also recorded in the repo,
+ - to git processes. The config setting is also recorded in the Repo,
- and the GitConfig is updated. -}
addGitConfigOverride :: String -> Annex ()
-addGitConfigOverride v = adjustGitRepo $ \r ->
- Git.Config.store (encodeBS' v) Git.Config.ConfigList $
- r { Git.gitGlobalOpts = go (Git.gitGlobalOpts r) }
+addGitConfigOverride v = do
+ adjustGitRepo $ \r ->
+ Git.Config.store (encodeBS' v) Git.Config.ConfigList $
+ r { Git.gitGlobalOpts = go (Git.gitGlobalOpts r) }
+ changeState $ \s -> s { gitconfigoverride = v : gitconfigoverride s }
where
-- Remove any prior occurrance of the setting to avoid
-- building up many of them when the adjustment is run repeatedly,
go (Param "-c": Param v':rest) | v' == v = go rest
go (c:rest) = c : go rest
+{- Values that were passed to addGitConfigOverride. -}
+getGitConfigOverrides :: Annex [String]
+getGitConfigOverrides = reverse <$> getState gitconfigoverride
+
{- Changing the git Repo data also involves re-extracting its GitConfig. -}
changeGitRepo :: Git.Repo -> Annex ()
changeGitRepo r = do
autoEnableSpecialRemotes :: Annex ()
autoEnableSpecialRemotes = do
rp <- fromRawFilePath <$> fromRepo Git.repoPath
- withNullHandle $ \nullh -> gitAnnexChildProcess
- [ "init"
- , "--autoenable"
- ]
+ withNullHandle $ \nullh -> gitAnnexChildProcess "init"
+ [ "--autoenable" ]
(\p -> p
{ std_out = UseHandle nullh
, std_err = UseHandle nullh
import Config.Files
import Utility.Env
import Annex.PidLock
+import qualified Annex
import System.Environment (getExecutablePath)
- to avoid it deadlocking.
-}
gitAnnexChildProcess
- :: [String]
+ :: String
+ -> [String]
-> (CreateProcess -> CreateProcess)
-> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> IO a)
-> Annex a
-gitAnnexChildProcess ps f a = do
+gitAnnexChildProcess subcmd ps f a = do
cmd <- liftIO programPath
- pidLockChildProcess cmd ps f a
+ -- Pass along git config values that were set on command line
+ -- to the child process.
+ cps <- concatMap (\c -> ["-c", c]) <$> Annex.getGitConfigOverrides
+ pidLockChildProcess cmd (subcmd:cps++ps) f a