git-annex config annex.largefiles

annex.largefiles can be configured by git-annex config, to more easily set
a default that will also be used by clones, without needing to shoehorn the
expression into the gitattributes file. The git config and gitattributes
override that.

Whenever something is added to git-annex config, we have to consider what
happens if a user puts a purposfully bad value in there. Or, if a new
git-annex adds some new value that an old git-annex can't parse.
In this case, a global annex.largefiles that can't be parsed currently
makes an error be thrown. That might not be ideal, but the gitattribute
behaves the same, and is almost equally repo-global.

Performance notes:

git-annex add and addurl construct a matcher once
and uses it for every file, so the added time penalty for reading the global
config log is minor. If the gitattributes annex.largefiles were deprecated,
git-annex add would get around 2% faster (excluding hashing), because
looking that up for each file is not fast. So this new way of setting
it is progress toward speeding up add.

git-annex smudge does need to load the log every time. As well as checking
the git attribute. Not ideal. Setting annex.gitaddtoannex=false avoids
both overheads.
This commit is contained in:
Joey Hess 2019-12-20 12:12:31 -04:00
parent ce3fb0b2e5
commit 4acbb40112
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
9 changed files with 119 additions and 63 deletions

View file

@ -1,6 +1,6 @@
{- git-annex configuration
-
- Copyright 2017 Joey Hess <id@joeyh.name>
- Copyright 2017-2019 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -20,20 +20,21 @@ import Logs.Config
- Note: Be sure to add the config value to mergeGitConfig.
-}
getGitConfigVal :: (GitConfig -> Configurable a) -> Annex a
getGitConfigVal f = do
v <- f <$> Annex.getGitConfig
case v of
HasConfig c -> return c
DefaultConfig _ -> do
r <- Annex.gitRepo
m <- loadGlobalConfig
let globalgc = extractGitConfig (r { config = m })
-- This merge of the repo-global config and the git
-- config makes all repository-global default
-- values populate the GitConfig with HasConfig
-- values, so it will only need to be done once.
Annex.changeGitConfig (\gc -> mergeGitConfig gc globalgc)
v' <- f <$> Annex.getGitConfig
case v' of
HasConfig c -> return c
DefaultConfig d -> return d
getGitConfigVal f = getGitConfigVal' f >>= \case
HasGlobalConfig c -> return c
DefaultConfig d -> return d
HasGitConfig c -> return c
getGitConfigVal' :: (GitConfig -> Configurable a) -> Annex (Configurable a)
getGitConfigVal' f = (f <$> Annex.getGitConfig) >>= \case
DefaultConfig _ -> do
r <- Annex.gitRepo
m <- loadGlobalConfig
let globalgc = extractGitConfig FromGlobalConfig (r { config = m })
-- This merge of the repo-global config and the git
-- 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)
f <$> Annex.getGitConfig
c -> return c