From 8adf318558c74393fbed0a746465c9b8e29a63a0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 2 Feb 2016 15:18:17 -0400 Subject: annex.largefiles can be configured in .gitattributes too This is particulary useful for v6 repositories, since the .gitattributes configuration will apply in all clones of the repository. --- Annex/CheckAttr.hs | 1 + Annex/FileMatcher.hs | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'Annex') diff --git a/Annex/CheckAttr.hs b/Annex/CheckAttr.hs index 28c5ffedd..2be95483e 100644 --- a/Annex/CheckAttr.hs +++ b/Annex/CheckAttr.hs @@ -20,6 +20,7 @@ annexAttrs :: [Git.Attr] annexAttrs = [ "annex.backend" , "annex.numcopies" + , "annex.largefiles" ] checkAttr :: Git.Attr -> FilePath -> Annex String diff --git a/Annex/FileMatcher.hs b/Annex/FileMatcher.hs index a8e431acf..4c7541b46 100644 --- a/Annex/FileMatcher.hs +++ b/Annex/FileMatcher.hs @@ -1,6 +1,6 @@ {- git-annex file matching - - - Copyright 2012-2014 Joey Hess + - Copyright 2012-2016 Joey Hess - - Licensed under the GNU GPL version 3 or higher. -} @@ -19,12 +19,18 @@ import qualified Annex import Types.FileMatcher import Git.FilePath import Types.Remote (RemoteConfig) +import Annex.CheckAttr +import Git.CheckAttr (unspecifiedAttr) import Data.Either import qualified Data.Set as S -checkFileMatcher :: FileMatcher Annex -> FilePath -> Annex Bool -checkFileMatcher matcher file = checkMatcher matcher Nothing (Just file) S.empty True +type GetFileMatcher = FilePath -> Annex (FileMatcher Annex) + +checkFileMatcher :: GetFileMatcher -> FilePath -> Annex Bool +checkFileMatcher getmatcher file = do + matcher <- getmatcher file + checkMatcher matcher Nothing (Just file) S.empty True checkMatcher :: FileMatcher Annex -> Maybe Key -> AssociatedFile -> AssumeNotPresent -> Bool -> Annex Bool checkMatcher matcher mkey afile notpresent d @@ -104,11 +110,19 @@ tokenizeMatcher = filter (not . null ) . concatMap splitparens . words {- Generates a matcher for files large enough (or meeting other criteria) - to be added to the annex, rather than directly to git. -} -largeFilesMatcher :: Annex (FileMatcher Annex) +largeFilesMatcher :: Annex GetFileMatcher largeFilesMatcher = go =<< annexLargeFiles <$> Annex.getGitConfig where - go Nothing = return matchAll go (Just expr) = do + matcher <- mkmatcher expr + return $ const $ return matcher + go Nothing = return $ \file -> do + expr <- checkAttr "annex.largefiles" file + if null expr || expr == unspecifiedAttr + then return matchAll + else mkmatcher expr + + mkmatcher expr = do u <- getUUID -- No need to read remote configs, that's only needed for -- inpreferreddir, which is used in preferred content -- cgit v1.2.3