From: Joey Hess Date: Thu, 27 Feb 2020 05:06:35 +0000 (-0400) Subject: rename changeGitConfig to overrideGitConfig and avoid unncessary calls X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~126^2~98 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c78b9b55b6b9e2a4d4531712fab570788c5a3202;p=git-annex.git rename changeGitConfig to overrideGitConfig and avoid unncessary calls It's important that it be clear that it overrides a config, such that reloading the git config won't change it, and in particular, setConfig won't change it. Most of the calls to changeGitConfig were actually after setConfig, which was redundant and unncessary. So removed those. The only remaining one, besides --debug, is in the handling of repository-global config values. That one's ok, because the way mergeGitConfig is implemented, it does not override any value that is set in git config. If a value with a repo-global setting was passed to setConfig, it would set it in the git config, reload the git config, re-apply mergeGitConfig, and use the newly set value, which is the right thing. --- diff --git a/Annex.hs b/Annex.hs index efdbe864d7..9e0bcd3d81 100644 --- a/Annex.hs +++ b/Annex.hs @@ -28,7 +28,7 @@ module Annex ( fromRepo, calcRepo, getGitConfig, - changeGitConfig, + overrideGitConfig, changeGitRepo, adjustGitRepo, getRemoteGitConfig, @@ -316,10 +316,10 @@ calcRepo a = do getGitConfig :: Annex GitConfig getGitConfig = getState gitconfig -{- Modifies a GitConfig setting. The modification persists across +{- Overrides a GitConfig setting. The modification persists across - reloads of the repo's config. -} -changeGitConfig :: (GitConfig -> GitConfig) -> Annex () -changeGitConfig f = changeState $ \s -> s +overrideGitConfig :: (GitConfig -> GitConfig) -> Annex () +overrideGitConfig f = changeState $ \s -> s { gitconfigadjustment = gitconfigadjustment s . f , gitconfig = f (gitconfig s) } diff --git a/Annex/UUID.hs b/Annex/UUID.hs index 1032acd14e..f4e6b85648 100644 --- a/Annex/UUID.hs +++ b/Annex/UUID.hs @@ -102,9 +102,7 @@ prepUUID = whenM ((==) NoUUID <$> getUUID) $ storeUUID =<< liftIO genUUID storeUUID :: UUID -> Annex () -storeUUID u = do - Annex.changeGitConfig $ \c -> c { annexUUID = u } - storeUUIDIn configkeyUUID u +storeUUID = storeUUIDIn configkeyUUID storeUUIDIn :: ConfigKey -> UUID -> Annex () storeUUIDIn configfield = setConfig configfield . fromUUID diff --git a/CmdLine/Option.hs b/CmdLine/Option.hs index ccc49bfc21..7957ba852d 100644 --- a/CmdLine/Option.hs +++ b/CmdLine/Option.hs @@ -59,5 +59,5 @@ commonGlobalOptions = setforce v = Annex.changeState $ \s -> s { Annex.force = v } setfast v = Annex.changeState $ \s -> s { Annex.fast = v } setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v } - setdebug = Annex.changeGitConfig $ \c -> c { annexDebug = True } - unsetdebug = Annex.changeGitConfig $ \c -> c { annexDebug = False } + setdebug = Annex.overrideGitConfig $ \c -> c { annexDebug = True } + unsetdebug = Annex.overrideGitConfig $ \c -> c { annexDebug = False } diff --git a/Config.hs b/Config.hs index 0f5f14d913..0196c16145 100644 --- a/Config.hs +++ b/Config.hs @@ -106,9 +106,8 @@ crippledFileSystem :: Annex Bool crippledFileSystem = annexCrippledFileSystem <$> Annex.getGitConfig setCrippledFileSystem :: Bool -> Annex () -setCrippledFileSystem b = do +setCrippledFileSystem b = setConfig (annexConfig "crippledfilesystem") (Git.Config.boolConfig b) - Annex.changeGitConfig $ \c -> c { annexCrippledFileSystem = b } yesNo :: String -> Maybe Bool yesNo "yes" = Just True diff --git a/Config/GitConfig.hs b/Config/GitConfig.hs index 6d5e161e78..1a63f7b7bb 100644 --- a/Config/GitConfig.hs +++ b/Config/GitConfig.hs @@ -35,6 +35,6 @@ getGitConfigVal' f = (f <$> Annex.getGitConfig) >>= \case -- config makes all repository-global default -- values populate the GitConfig with HasGlobalConfig -- values, so it will only need to be done once. - Annex.changeGitConfig (\gc -> mergeGitConfig gc globalgc) + Annex.overrideGitConfig (\gc -> mergeGitConfig gc globalgc) f <$> Annex.getGitConfig c -> return c diff --git a/Upgrade/V5.hs b/Upgrade/V5.hs index a8a84283b3..0e0368d11d 100644 --- a/Upgrade/V5.hs +++ b/Upgrade/V5.hs @@ -10,7 +10,6 @@ module Upgrade.V5 where import Annex.Common -import qualified Annex import Config import Config.Smudge import Annex.InodeSentinal @@ -84,7 +83,6 @@ convertDirect = do - space, with less preservation of old versions of files - as does annex.thin. -} setConfig (annexConfig "thin") (boolConfig True) - Annex.changeGitConfig $ \c -> c { annexThin = True } Direct.setIndirect cur <- fromMaybe (error "Somehow no branch is checked out") <$> inRepo Git.Branch.current diff --git a/Upgrade/V5/Direct.hs b/Upgrade/V5/Direct.hs index 600efc616d..1fcf8c4eeb 100644 --- a/Upgrade/V5/Direct.hs +++ b/Upgrade/V5/Direct.hs @@ -19,7 +19,6 @@ module Upgrade.V5.Direct ( ) where import Annex.Common -import qualified Annex import qualified Git import qualified Git.Config import qualified Git.Ref @@ -35,7 +34,6 @@ setIndirect = do setbare switchHEADBack setConfig (annexConfig "direct") val - Annex.changeGitConfig $ \c -> c { annexDirect = False } where val = Git.Config.boolConfig False coreworktree = ConfigKey "core.worktree"