aboutsummaryrefslogtreecommitdiff
path: root/Annex/FileMatcher.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-02-02 15:18:17 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-02-02 15:18:17 -0400
commit8adf318558c74393fbed0a746465c9b8e29a63a0 (patch)
tree410cbb527939465949ce0f99ac2d2d3f686b74ce /Annex/FileMatcher.hs
parent81457e02ddf833df56112a8afaf25f57ecd07076 (diff)
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.
Diffstat (limited to 'Annex/FileMatcher.hs')
-rw-r--r--Annex/FileMatcher.hs24
1 files changed, 19 insertions, 5 deletions
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 <id@joeyh.name>
+ - Copyright 2012-2016 Joey Hess <id@joeyh.name>
-
- 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