aboutsummaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-22 13:47:41 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-22 13:47:41 -0400
commit332f4ed6fbc930bf46984a512f300b29edc17d3b (patch)
treefa60e5a9676ef26f1b4e1eb6ec90ea9de7e95b00 /Annex.hs
parent6cb031140c734b6c80e85a31b7ecbba7ddfb65a7 (diff)
Bug fix: Git config settings passed to git-annex -c did not always take effect.
When Config.setConfig runs, it throws away the old Repo and loads a new one. So, add an action to adjust the Repo so that -c settings will persist across that.
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs21
1 files changed, 17 insertions, 4 deletions
diff --git a/Annex.hs b/Annex.hs
index 4f26c497c..d9c512f3f 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -30,6 +30,7 @@ module Annex (
getGitConfig,
changeGitConfig,
changeGitRepo,
+ adjustGitRepo,
getRemoteGitConfig,
withCurrentState,
changeDirectory,
@@ -95,6 +96,7 @@ newtype Annex a = Annex { runAnnex :: ReaderT (MVar AnnexState) IO a }
-- internal state storage
data AnnexState = AnnexState
{ repo :: Git.Repo
+ , repoadjustment :: (Git.Repo -> IO Git.Repo)
, gitconfig :: GitConfig
, backends :: [BackendA Annex]
, remotes :: [Types.Remote.RemoteA Annex]
@@ -141,6 +143,7 @@ data AnnexState = AnnexState
newState :: GitConfig -> Git.Repo -> AnnexState
newState c r = AnnexState
{ repo = r
+ , repoadjustment = return
, gitconfig = c
, backends = []
, remotes = []
@@ -295,10 +298,20 @@ changeGitConfig a = changeState $ \s -> s { gitconfig = a (gitconfig s) }
{- Changing the git Repo data also involves re-extracting its GitConfig. -}
changeGitRepo :: Git.Repo -> Annex ()
-changeGitRepo r = changeState $ \s -> s
- { repo = r
- , gitconfig = extractGitConfig r
- }
+changeGitRepo r = do
+ adjuster <- getState repoadjustment
+ r' <- liftIO $ adjuster r
+ changeState $ \s -> s
+ { repo = r'
+ , gitconfig = extractGitConfig r'
+ }
+
+{- Adds an adjustment to the Repo data. Adjustments persist across reloads
+ - of the repo's config. -}
+adjustGitRepo :: (Git.Repo -> IO Git.Repo) -> Annex ()
+adjustGitRepo a = do
+ changeState $ \s -> s { repoadjustment = \r -> repoadjustment s r >>= a }
+ changeGitRepo =<< gitRepo
{- Gets the RemoteGitConfig from a remote, given the Git.Repo for that
- remote. -}