refix bug in a better way
Always run Git.Config.store, so when the git config gets reloaded, the override gets re-added to it, and changeGitRepo then calls extractGitConfig on it and sees the annex.* settings from the override. Remove any prior occurance of -c v and add it to the end. This way, -c foo=1 -c foo=2 -c foo=1 will pass -c foo=1 to git, rather than -c foo=2 Note that, if git had some multiline config that got built up by multiple -c's, this would not work still. But it never worked because before the bug got fixed in the first place, the -c value was repeated many times, so the multivalue thing would have been wrong. I don't think -c can be used with multiline configs anyway, though git-config does talk about them?
This commit is contained in:
parent
ec0f8a6e74
commit
f912f8e5fd
5 changed files with 38 additions and 5 deletions
16
Annex.hs
16
Annex.hs
|
@ -31,6 +31,7 @@ module Annex (
|
|||
overrideGitConfig,
|
||||
changeGitRepo,
|
||||
adjustGitRepo,
|
||||
addGitConfigOverride,
|
||||
getRemoteGitConfig,
|
||||
withCurrentState,
|
||||
changeDirectory,
|
||||
|
@ -338,6 +339,21 @@ adjustGitRepo a = do
|
|||
changeState $ \s -> s { repoadjustment = \r -> repoadjustment s r >>= a }
|
||||
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,
|
||||
- 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) }
|
||||
where
|
||||
-- Remove any prior occurrance of the setting to avoid
|
||||
-- building up many of them when the adjustment is run repeatedly,
|
||||
-- and add the setting to the end.
|
||||
go [] = [Param "-c", Param v]
|
||||
go (Param "-c": Param v':rest) | v' == v = go rest
|
||||
go (c:rest) = c : go rest
|
||||
|
||||
{- Changing the git Repo data also involves re-extracting its GitConfig. -}
|
||||
changeGitRepo :: Git.Repo -> Annex ()
|
||||
changeGitRepo r = do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue