summaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-26 13:49:22 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-26 14:35:39 -0400
commitcbfcd75214a648bf204f8356a28e360229542bde (patch)
tree4b63d28522c4c73dc4847d66fffe1bcf3864c0b9 /Limit.hs
parentc7e198390bfe3911943bc74836d7519c5ae37674 (diff)
fix * glob matching files in subdirectories
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs18
1 files changed, 5 insertions, 13 deletions
diff --git a/Limit.hs b/Limit.hs
index df188e3df..1d02decbe 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -12,12 +12,8 @@ module Limit where
import Data.Time.Clock.POSIX
import qualified Data.Set as S
import qualified Data.Map as M
-#ifdef WITH_GLOB
-import "Glob" System.FilePath.Glob (simplify, compile, match)
-#else
-import Text.Regex.PCRE.Light.Char8
import System.Path.WildMatch
-#endif
+import Text.Regex
import Common.Annex
import qualified Annex
@@ -86,18 +82,14 @@ addExclude = addLimit . limitExclude
limitExclude :: MkLimit
limitExclude glob = Right $ const $ return . not . matchglob glob
+{- Could just use wildCheckCase, but this way the regex is only compiled
+ - once. -}
matchglob :: String -> Annex.FileInfo -> Bool
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
-#ifdef WITH_GLOB
- match pattern f
+ isJust $ matchRegex cregex f
where
- pattern = simplify $ compile glob
-#else
- isJust $ match cregex f []
- where
- cregex = compile regex []
+ cregex = mkRegex regex
regex = '^':wildToRegex glob
-#endif
{- Adds a limit to skip files not believed to be present
- in a specfied repository. -}