fix * glob matching files in subdirectories
This commit is contained in:
parent
1e3aa441f0
commit
7df2861d67
4 changed files with 18 additions and 16 deletions
18
Limit.hs
18
Limit.hs
|
@ -12,12 +12,8 @@ module Limit where
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import qualified Data.Map as M
|
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
|
import System.Path.WildMatch
|
||||||
#endif
|
import Text.Regex
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
@ -86,18 +82,14 @@ addExclude = addLimit . limitExclude
|
||||||
limitExclude :: MkLimit
|
limitExclude :: MkLimit
|
||||||
limitExclude glob = Right $ const $ return . not . matchglob glob
|
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 :: String -> Annex.FileInfo -> Bool
|
||||||
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
|
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
|
||||||
#ifdef WITH_GLOB
|
isJust $ matchRegex cregex f
|
||||||
match pattern f
|
|
||||||
where
|
where
|
||||||
pattern = simplify $ compile glob
|
cregex = mkRegex regex
|
||||||
#else
|
|
||||||
isJust $ match cregex f []
|
|
||||||
where
|
|
||||||
cregex = compile regex []
|
|
||||||
regex = '^':wildToRegex glob
|
regex = '^':wildToRegex glob
|
||||||
#endif
|
|
||||||
|
|
||||||
{- Adds a limit to skip files not believed to be present
|
{- Adds a limit to skip files not believed to be present
|
||||||
- in a specfied repository. -}
|
- in a specfied repository. -}
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -16,6 +16,9 @@ git-annex (3.20130217) UNRELEASED; urgency=low
|
||||||
* Additional GIT_DIR support bugfixes. May actually work now.
|
* Additional GIT_DIR support bugfixes. May actually work now.
|
||||||
* webapp: Display any error message from git init if it fails to create
|
* webapp: Display any error message from git init if it fails to create
|
||||||
a repository.
|
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 <joeyh@debian.org> Sun, 17 Feb 2013 16:42:16 -0400
|
-- Joey Hess <joeyh@debian.org> Sun, 17 Feb 2013 16:42:16 -0400
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,13 @@ Executable git-annex
|
||||||
extensible-exceptions, dataenc, SHA, process, json,
|
extensible-exceptions, dataenc, SHA, process, json,
|
||||||
base (>= 4.5 && < 4.8), monad-control, transformers-base, lifted-base,
|
base (>= 4.5 && < 4.8), monad-control, transformers-base, lifted-base,
|
||||||
IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process,
|
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.
|
-- Need to list these because they're generated from .hsc files.
|
||||||
Other-Modules: Utility.Touch Utility.Mounts
|
Other-Modules: Utility.Touch Utility.Mounts
|
||||||
Include-Dirs: Utility
|
Include-Dirs: Utility
|
||||||
C-Sources: Utility/libdiskfree.c Utility/libmounts.c
|
C-Sources: Utility/libdiskfree.c Utility/libmounts.c
|
||||||
Extensions: CPP
|
Extensions: CPP
|
||||||
GHC-Options: -threaded
|
GHC-Options: -threaded
|
||||||
CPP-Options: -DWITH_GLOB
|
|
||||||
|
|
||||||
if flag(S3)
|
if flag(S3)
|
||||||
Build-Depends: hS3
|
Build-Depends: hS3
|
||||||
|
@ -127,7 +126,7 @@ Test-Suite test
|
||||||
old-locale, time, extensible-exceptions, dataenc, SHA,
|
old-locale, time, extensible-exceptions, dataenc, SHA,
|
||||||
process, json, base (>= 4.5 && < 4.7), monad-control,
|
process, json, base (>= 4.5 && < 4.7), monad-control,
|
||||||
transformers-base, lifted-base, IfElse, text, QuickCheck >= 2.1,
|
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
|
Other-Modules: Utility.Touch
|
||||||
Include-Dirs: Utility
|
Include-Dirs: Utility
|
||||||
C-Sources: Utility/libdiskfree.c
|
C-Sources: Utility/libdiskfree.c
|
||||||
|
|
8
test.hs
8
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", "SHA1"] [sha1annexedfile]
|
||||||
git_annex_expectoutput "find" ["--inbackend", "WORM"] []
|
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 :: Test
|
||||||
test_merge = "git-annex merge" ~: intmpclonerepo $ do
|
test_merge = "git-annex merge" ~: intmpclonerepo $ do
|
||||||
git_annex "merge" [] @? "merge failed"
|
git_annex "merge" [] @? "merge failed"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue