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:
parent
ce3fb0b2e5
commit
4acbb40112
9 changed files with 119 additions and 63 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
module Types.GitConfig (
|
||||
Configurable(..),
|
||||
ConfigSource(..),
|
||||
GitConfig(..),
|
||||
extractGitConfig,
|
||||
mergeGitConfig,
|
||||
|
@ -46,13 +47,17 @@ import qualified Data.Set as S
|
|||
-- | A configurable value, that may not be fully determined yet because
|
||||
-- the global git config has not yet been loaded.
|
||||
data Configurable a
|
||||
= HasConfig a
|
||||
-- ^ Value is fully determined.
|
||||
= HasGitConfig a
|
||||
-- ^ The git config has a value.
|
||||
| HasGlobalConfig a
|
||||
-- ^ The global config has a value (and the git config does not).
|
||||
| DefaultConfig a
|
||||
-- ^ A default value is known, but not all config sources
|
||||
-- have been read yet.
|
||||
deriving (Show)
|
||||
|
||||
data ConfigSource = FromGitConfig | FromGlobalConfig
|
||||
|
||||
{- Main git-annex settings. Each setting corresponds to a git-config key
|
||||
- such as annex.foo -}
|
||||
data GitConfig = GitConfig
|
||||
|
@ -80,7 +85,7 @@ data GitConfig = GitConfig
|
|||
, annexYoutubeDlOptions :: [String]
|
||||
, annexAriaTorrentOptions :: [String]
|
||||
, annexCrippledFileSystem :: Bool
|
||||
, annexLargeFiles :: Maybe String
|
||||
, annexLargeFiles :: Configurable (Maybe String)
|
||||
, annexGitAddToAnnex :: Bool
|
||||
, annexAddSmallFiles :: Bool
|
||||
, annexFsckNudge :: Bool
|
||||
|
@ -116,8 +121,8 @@ data GitConfig = GitConfig
|
|||
, gpgCmd :: GpgCmd
|
||||
}
|
||||
|
||||
extractGitConfig :: Git.Repo -> GitConfig
|
||||
extractGitConfig r = GitConfig
|
||||
extractGitConfig :: ConfigSource -> Git.Repo -> GitConfig
|
||||
extractGitConfig configsource r = GitConfig
|
||||
{ annexVersion = RepoVersion <$> getmayberead (annex "version")
|
||||
, annexUUID = maybe NoUUID toUUID $ getmaybe (annex "uuid")
|
||||
, annexNumCopies = NumCopies <$> getmayberead (annex "numcopies")
|
||||
|
@ -151,7 +156,8 @@ extractGitConfig r = GitConfig
|
|||
, annexYoutubeDlOptions = getwords (annex "youtube-dl-options")
|
||||
, annexAriaTorrentOptions = getwords (annex "aria-torrent-options")
|
||||
, annexCrippledFileSystem = getbool (annex "crippledfilesystem") False
|
||||
, annexLargeFiles = getmaybe (annex "largefiles")
|
||||
, annexLargeFiles = configurable Nothing $
|
||||
fmap Just $ getmaybe (annex "largefiles")
|
||||
, annexGitAddToAnnex = getbool (annex "gitaddtoannex") True
|
||||
, annexAddSmallFiles = getbool (annex "addsmallfiles") True
|
||||
, annexFsckNudge = getbool (annex "fscknudge") True
|
||||
|
@ -209,7 +215,9 @@ extractGitConfig r = GitConfig
|
|||
getwords k = fromMaybe [] $ words <$> getmaybe k
|
||||
|
||||
configurable d Nothing = DefaultConfig d
|
||||
configurable _ (Just v) = HasConfig v
|
||||
configurable _ (Just v) = case configsource of
|
||||
FromGitConfig -> HasGitConfig v
|
||||
FromGlobalConfig -> HasGlobalConfig v
|
||||
|
||||
annex k = ConfigKey $ "annex." <> k
|
||||
|
||||
|
@ -222,13 +230,15 @@ mergeGitConfig gitconfig repoglobals = gitconfig
|
|||
{ annexAutoCommit = merge annexAutoCommit
|
||||
, annexSyncContent = merge annexSyncContent
|
||||
, annexResolveMerge = merge annexResolveMerge
|
||||
, annexLargeFiles = merge annexLargeFiles
|
||||
}
|
||||
where
|
||||
merge f = case f gitconfig of
|
||||
HasConfig v -> HasConfig v
|
||||
HasGitConfig v -> HasGitConfig v
|
||||
DefaultConfig d -> case f repoglobals of
|
||||
HasConfig v -> HasConfig v
|
||||
DefaultConfig _ -> HasConfig d
|
||||
HasGlobalConfig v -> HasGlobalConfig v
|
||||
_ -> HasGitConfig d
|
||||
HasGlobalConfig v -> HasGlobalConfig v
|
||||
|
||||
{- Per-remote git-annex settings. Each setting corresponds to a git-config
|
||||
- key such as <remote>.annex-foo, or if that is not set, a default from
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue