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.
This commit is contained in:
parent
ee14601890
commit
99c646615d
3 changed files with 21 additions and 7 deletions
19
Annex.hs
19
Annex.hs
|
@ -30,6 +30,7 @@ module Annex (
|
||||||
getGitConfig,
|
getGitConfig,
|
||||||
changeGitConfig,
|
changeGitConfig,
|
||||||
changeGitRepo,
|
changeGitRepo,
|
||||||
|
adjustGitRepo,
|
||||||
getRemoteGitConfig,
|
getRemoteGitConfig,
|
||||||
withCurrentState,
|
withCurrentState,
|
||||||
changeDirectory,
|
changeDirectory,
|
||||||
|
@ -95,6 +96,7 @@ newtype Annex a = Annex { runAnnex :: ReaderT (MVar AnnexState) IO a }
|
||||||
-- internal state storage
|
-- internal state storage
|
||||||
data AnnexState = AnnexState
|
data AnnexState = AnnexState
|
||||||
{ repo :: Git.Repo
|
{ repo :: Git.Repo
|
||||||
|
, repoadjustment :: (Git.Repo -> IO Git.Repo)
|
||||||
, gitconfig :: GitConfig
|
, gitconfig :: GitConfig
|
||||||
, backends :: [BackendA Annex]
|
, backends :: [BackendA Annex]
|
||||||
, remotes :: [Types.Remote.RemoteA Annex]
|
, remotes :: [Types.Remote.RemoteA Annex]
|
||||||
|
@ -141,6 +143,7 @@ data AnnexState = AnnexState
|
||||||
newState :: GitConfig -> Git.Repo -> AnnexState
|
newState :: GitConfig -> Git.Repo -> AnnexState
|
||||||
newState c r = AnnexState
|
newState c r = AnnexState
|
||||||
{ repo = r
|
{ repo = r
|
||||||
|
, repoadjustment = return
|
||||||
, gitconfig = c
|
, gitconfig = c
|
||||||
, backends = []
|
, backends = []
|
||||||
, remotes = []
|
, remotes = []
|
||||||
|
@ -295,11 +298,21 @@ changeGitConfig a = changeState $ \s -> s { gitconfig = a (gitconfig s) }
|
||||||
|
|
||||||
{- Changing the git Repo data also involves re-extracting its GitConfig. -}
|
{- Changing the git Repo data also involves re-extracting its GitConfig. -}
|
||||||
changeGitRepo :: Git.Repo -> Annex ()
|
changeGitRepo :: Git.Repo -> Annex ()
|
||||||
changeGitRepo r = changeState $ \s -> s
|
changeGitRepo r = do
|
||||||
{ repo = r
|
adjuster <- getState repoadjustment
|
||||||
, gitconfig = extractGitConfig r
|
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
|
{- Gets the RemoteGitConfig from a remote, given the Git.Repo for that
|
||||||
- remote. -}
|
- remote. -}
|
||||||
getRemoteGitConfig :: Git.Repo -> Annex RemoteGitConfig
|
getRemoteGitConfig :: Git.Repo -> Annex RemoteGitConfig
|
||||||
|
|
|
@ -87,9 +87,8 @@ gitAnnexGlobalOptions = commonGlobalOptions ++
|
||||||
where
|
where
|
||||||
setnumcopies n = Annex.changeState $ \s -> s { Annex.forcenumcopies = Just $ NumCopies n }
|
setnumcopies n = Annex.changeState $ \s -> s { Annex.forcenumcopies = Just $ NumCopies n }
|
||||||
setuseragent v = Annex.changeState $ \s -> s { Annex.useragent = Just v }
|
setuseragent v = Annex.changeState $ \s -> s { Annex.useragent = Just v }
|
||||||
setgitconfig v = inRepo (Git.Config.store v)
|
setgitconfig v = Annex.adjustGitRepo $ \r -> Git.Config.store v $
|
||||||
>>= pure . (\r -> r { gitGlobalOpts = gitGlobalOpts r ++ [Param "-c", Param v] })
|
r { gitGlobalOpts = gitGlobalOpts r ++ [Param "-c", Param v] }
|
||||||
>>= Annex.changeGitRepo
|
|
||||||
setdesktopnotify v = Annex.changeState $ \s -> s { Annex.desktopnotify = Annex.desktopnotify s <> v }
|
setdesktopnotify v = Annex.changeState $ \s -> s { Annex.desktopnotify = Annex.desktopnotify s <> v }
|
||||||
|
|
||||||
{- Parser that accepts all non-option params. -}
|
{- Parser that accepts all non-option params. -}
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -11,6 +11,8 @@ git-annex (6.20160115) UNRELEASED; urgency=medium
|
||||||
added directly to git due to annex.largefiles configuration.)
|
added directly to git due to annex.largefiles configuration.)
|
||||||
(Also done by add --json and import --json)
|
(Also done by add --json and import --json)
|
||||||
* registerurl: Check if a remote claims the url, same as addurl does.
|
* registerurl: Check if a remote claims the url, same as addurl does.
|
||||||
|
* Bug fix: Git config settings passed to git-annex -c did not always take
|
||||||
|
effect.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400
|
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue