diff --git a/Limit.hs b/Limit.hs index df188e3df0..1d02decbe2 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. -} diff --git a/debian/changelog b/debian/changelog index cb384bc6e6..9f68bc5233 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,9 @@ git-annex (3.20130217) UNRELEASED; urgency=low * Additional GIT_DIR support bugfixes. May actually work now. * webapp: Display any error message from git init if it fails to create a repository. + * Fix a reversion in matching globs introduced in the last release, + where "*" did not match files inside subdirectories. No longer uses + the Glob library. -- Joey Hess Sun, 17 Feb 2013 16:42:16 -0400 diff --git a/git-annex.cabal b/git-annex.cabal index 6bfb8a06e2..3383a6895f 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -60,14 +60,13 @@ Executable git-annex extensible-exceptions, dataenc, SHA, process, json, base (>= 4.5 && < 4.8), monad-control, transformers-base, lifted-base, IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process, - SafeSemaphore, uuid, random, Glob + SafeSemaphore, uuid, random -- Need to list these because they're generated from .hsc files. Other-Modules: Utility.Touch Utility.Mounts Include-Dirs: Utility C-Sources: Utility/libdiskfree.c Utility/libmounts.c Extensions: CPP GHC-Options: -threaded - CPP-Options: -DWITH_GLOB if flag(S3) Build-Depends: hS3 @@ -127,7 +126,7 @@ Test-Suite test old-locale, time, extensible-exceptions, dataenc, SHA, process, json, base (>= 4.5 && < 4.7), monad-control, transformers-base, lifted-base, IfElse, text, QuickCheck >= 2.1, - bloomfilter, edit-distance, process, SafeSemaphore, Glob, random, uuid + bloomfilter, edit-distance, process, SafeSemaphore, random, uuid Other-Modules: Utility.Touch Include-Dirs: Utility C-Sources: Utility/libdiskfree.c diff --git a/test.hs b/test.hs index 03c0c4e3a1..87898b4b5b 100644 --- a/test.hs +++ b/test.hs @@ -560,6 +560,14 @@ test_find = "git-annex find" ~: intmpclonerepo $ do git_annex_expectoutput "find" ["--inbackend", "SHA1"] [sha1annexedfile] git_annex_expectoutput "find" ["--inbackend", "WORM"] [] + {- --include=* should match files in subdirectories too, + - and --exclude=* should exclude them. -} + createDirectory "dir" + writeFile "dir/subfile" "subfile" + git_annex "add" ["dir"] @? "add of subdir failed" + git_annex_expectoutput "find" ["--include", "*", "--exclude", annexedfile, "--exclude", sha1annexedfile] ["dir/subfile"] + git_annex_expectoutput "find" ["--exclude", "*"] [] + test_merge :: Test test_merge = "git-annex merge" ~: intmpclonerepo $ do git_annex "merge" [] @? "merge failed"