summaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-22 13:53:06 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-22 14:00:17 -0400
commit6bffe509d7f1ec60168522585925a43dbfffbd36 (patch)
treea7fead7d1e5539139894f10c45f6d6c3d8d5cdc9 /Limit.hs
parent30cf6ce81ca8ff99f5284c5b991e546eb1da72ae (diff)
Add --include, which is the same as --not --exclude.
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/Limit.hs b/Limit.hs
index c68c3bdd8..26e5d689c 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -55,10 +55,16 @@ addLimit :: (FilePath -> Annex Bool) -> Annex ()
addLimit = add . Utility.Matcher.Operation
{- Add a limit to skip files that do not match the glob. -}
+addInclude :: String -> Annex ()
+addInclude glob = addLimit $ return . matchglob glob
+
+{- Add a limit to skip files that match the glob. -}
addExclude :: String -> Annex ()
-addExclude glob = addLimit $ return . notExcluded
+addExclude glob = addLimit $ return . not . matchglob glob
+
+matchglob :: String -> FilePath -> Bool
+matchglob glob f = isJust $ match cregex f []
where
- notExcluded f = isNothing $ match cregex f []
cregex = compile regex []
regex = '^':wildToRegex glob