Bugfix: Don't ignore --debug when it is followed by -c

This commit is contained in:
Joey Hess 2020-02-27 00:52:37 -04:00
parent ba4a2d8734
commit c089f395b0
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 52 additions and 14 deletions

View file

@ -1,6 +1,6 @@
{- git-annex monad
-
- Copyright 2010-2018 Joey Hess <id@joeyh.name>
- Copyright 2010-2020 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -104,6 +104,7 @@ data AnnexState = AnnexState
{ repo :: Git.Repo
, repoadjustment :: (Git.Repo -> IO Git.Repo)
, gitconfig :: GitConfig
, gitconfigadjustment :: (GitConfig -> GitConfig)
, gitremotes :: Maybe [Git.Repo]
, backend :: Maybe (BackendA Annex)
, remotes :: [Types.Remote.RemoteA Annex]
@ -161,6 +162,7 @@ newState c r = do
{ repo = r
, repoadjustment = return
, gitconfig = c
, gitconfigadjustment = id
, gitremotes = Nothing
, backend = Nothing
, remotes = []
@ -314,19 +316,13 @@ calcRepo a = do
getGitConfig :: Annex GitConfig
getGitConfig = getState gitconfig
{- Modifies a GitConfig setting. -}
{- Modifies a GitConfig setting. The modification persists across
- reloads of the repo's config. -}
changeGitConfig :: (GitConfig -> GitConfig) -> Annex ()
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 = do
adjuster <- getState repoadjustment
r' <- liftIO $ adjuster r
changeState $ \s -> s
{ repo = r'
, gitconfig = extractGitConfig FromGitConfig r'
}
changeGitConfig f = changeState $ \s -> s
{ gitconfigadjustment = gitconfigadjustment s . f
, gitconfig = f (gitconfig s)
}
{- Adds an adjustment to the Repo data. Adjustments persist across reloads
- of the repo's config. -}
@ -335,6 +331,18 @@ adjustGitRepo a = do
changeState $ \s -> s { repoadjustment = \r -> repoadjustment s r >>= a }
changeGitRepo =<< gitRepo
{- Changing the git Repo data also involves re-extracting its GitConfig. -}
changeGitRepo :: Git.Repo -> Annex ()
changeGitRepo r = do
repoadjuster <- getState repoadjustment
gitconfigadjuster <- getState gitconfigadjustment
r' <- liftIO $ repoadjuster r
changeState $ \s -> s
{ repo = r'
, gitconfig = gitconfigadjuster $
extractGitConfig FromGitConfig r'
}
{- Gets the RemoteGitConfig from a remote, given the Git.Repo for that
- remote. -}
getRemoteGitConfig :: Git.Repo -> Annex RemoteGitConfig

View file

@ -1,3 +1,9 @@
git-annex (8.20200227) UNRELEASED; urgency=medium
* Bugfix: Don't ignore --debug when it is followed by -c.
-- Joey Hess <id@joeyh.name> Thu, 27 Feb 2020 00:44:11 -0400
git-annex (8.20200226) upstream; urgency=medium
* New v8 repository version.

View file

@ -64,4 +64,4 @@ git-annex version: 7.20190819+git2-g908476a9b-1~ndall+1
[[!meta author=yoh]]
[[!tag projects/datalad]]
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,24 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2020-02-27T04:20:58Z"
content="""
-c uses adjustGitRepo which calls changeGitRepo, which
re-extracts the GitConfig. --debug uses changeGitConfig which
sets annexDebug in the GitConfig, which does not survive the changeGitRepo.
There might be a broader problem here, as changeGitRepo is also
called by setConfig in many parts of the code. I think it narrowly
escapes being a problem, because by the time a command is started,
it's already enabled debug output, and so the GitConfig being reloaded
doesn't disable debugging.
Other calls to changeGitConfig could also be a problem, if followed by
an adjustGitRepo which loses those changes. There are only a few others,
look probably ok, but this would be an easy gotcha to hit later.
So changeGitConfig needs to make a config change that persists across
changeGitRepo.
Done.
"""]]