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.
This commit is contained in:
parent
c089f395b0
commit
c78b9b55b6
7 changed files with 9 additions and 16 deletions
8
Annex.hs
8
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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue