Add --include, which is the same as --not --exclude.
This commit is contained in:
parent
30cf6ce81c
commit
6bffe509d7
6 changed files with 28 additions and 10 deletions
|
@ -9,8 +9,6 @@ module Git.Index where
|
||||||
|
|
||||||
import System.Posix.Env (setEnv, unsetEnv, getEnv)
|
import System.Posix.Env (setEnv, unsetEnv, getEnv)
|
||||||
|
|
||||||
import Common
|
|
||||||
|
|
||||||
{- Forces git to use the specified index file.
|
{- Forces git to use the specified index file.
|
||||||
-
|
-
|
||||||
- Returns an action that will reset back to the default
|
- Returns an action that will reset back to the default
|
||||||
|
|
|
@ -112,6 +112,8 @@ options = commonOptions ++
|
||||||
"terminate filename with null"
|
"terminate filename with null"
|
||||||
, Option ['x'] ["exclude"] (ReqArg Limit.addExclude paramGlob)
|
, Option ['x'] ["exclude"] (ReqArg Limit.addExclude paramGlob)
|
||||||
"skip files matching the glob pattern"
|
"skip files matching the glob pattern"
|
||||||
|
, Option ['I'] ["include"] (ReqArg Limit.addInclude paramGlob)
|
||||||
|
"don't skip files matching the glob pattern"
|
||||||
, Option ['i'] ["in"] (ReqArg Limit.addIn paramRemote)
|
, Option ['i'] ["in"] (ReqArg Limit.addIn paramRemote)
|
||||||
"skip files not present in a remote"
|
"skip files not present in a remote"
|
||||||
, Option ['C'] ["copies"] (ReqArg Limit.addCopies paramNumber)
|
, Option ['C'] ["copies"] (ReqArg Limit.addCopies paramNumber)
|
||||||
|
|
10
Limit.hs
10
Limit.hs
|
@ -55,10 +55,16 @@ addLimit :: (FilePath -> Annex Bool) -> Annex ()
|
||||||
addLimit = add . Utility.Matcher.Operation
|
addLimit = add . Utility.Matcher.Operation
|
||||||
|
|
||||||
{- Add a limit to skip files that do not match the glob. -}
|
{- 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 :: 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
|
where
|
||||||
notExcluded f = isNothing $ match cregex f []
|
|
||||||
cregex = compile regex []
|
cregex = compile regex []
|
||||||
regex = '^':wildToRegex glob
|
regex = '^':wildToRegex glob
|
||||||
|
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -7,6 +7,7 @@ git-annex (3.20111212) UNRELEASED; urgency=low
|
||||||
* map: --fast disables use of dot to display map
|
* map: --fast disables use of dot to display map
|
||||||
* Test suite improvements. Current top-level test coverage: 75%
|
* Test suite improvements. Current top-level test coverage: 75%
|
||||||
* Improve deletion of files from rsync special remotes. Closes: #652849
|
* Improve deletion of files from rsync special remotes. Closes: #652849
|
||||||
|
* Add --include, which is the same as --not --exclude.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Mon, 12 Dec 2011 01:57:49 -0400
|
-- Joey Hess <joeyh@debian.org> Mon, 12 Dec 2011 01:57:49 -0400
|
||||||
|
|
||||||
|
|
|
@ -241,12 +241,13 @@ subdirectories).
|
||||||
|
|
||||||
* find [path ...]
|
* find [path ...]
|
||||||
|
|
||||||
Outputs a list of annexed files whose content is currently present.
|
Outputs a list of annexed files in the specified path. With no path,
|
||||||
Or, if a file matching option is specified, outputs a list of all
|
finds files in the current directory and its subdirectories.
|
||||||
matching files, whether or not their content is currently present.
|
|
||||||
|
|
||||||
With no parameters, defaults to finding all files in the current directory
|
By default, only lists annexed files whose content is currently present.
|
||||||
and its subdirectories.
|
This can be changed by specifying file matching options. To list all
|
||||||
|
annexed files, present or not, specify --include "*". To list all
|
||||||
|
annexed files whose content is not present, specify --not --in "."
|
||||||
|
|
||||||
To output filenames terminated with nulls, for use with xargs -0,
|
To output filenames terminated with nulls, for use with xargs -0,
|
||||||
specify --print0.
|
specify --print0.
|
||||||
|
@ -447,7 +448,16 @@ file contents are present at either of two repositories.
|
||||||
* --exclude=glob
|
* --exclude=glob
|
||||||
|
|
||||||
Skips files matching the glob pattern. The glob is matched relative to
|
Skips files matching the glob pattern. The glob is matched relative to
|
||||||
the current directory. For example: --exclude='*.mp3' --exclude='subdir/*'
|
the current directory. For example:
|
||||||
|
|
||||||
|
--exclude='*.mp3' --exclude='subdir/*'
|
||||||
|
|
||||||
|
* --include=glob
|
||||||
|
|
||||||
|
Skips files not matching the glob pattern. (Same as --not --exclude.)
|
||||||
|
For example, to include only mp3 and ogg files:
|
||||||
|
|
||||||
|
--include='*.mp3' --or --include='*.ogg'
|
||||||
|
|
||||||
* --in=repository
|
* --in=repository
|
||||||
|
|
||||||
|
|
1
test.hs
1
test.hs
|
@ -524,6 +524,7 @@ test_find = "git-annex find" ~: intmpclonerepo $ do
|
||||||
annexed_notpresent sha1annexedfile
|
annexed_notpresent sha1annexedfile
|
||||||
git_annex_expectoutput "find" [] [annexedfile]
|
git_annex_expectoutput "find" [] [annexedfile]
|
||||||
git_annex_expectoutput "find" ["--exclude", annexedfile, "--and", "--exclude", sha1annexedfile] []
|
git_annex_expectoutput "find" ["--exclude", annexedfile, "--and", "--exclude", sha1annexedfile] []
|
||||||
|
git_annex_expectoutput "find" ["--include", annexedfile] [annexedfile]
|
||||||
git_annex_expectoutput "find" ["--not", "--in", "origin"] []
|
git_annex_expectoutput "find" ["--not", "--in", "origin"] []
|
||||||
git_annex_expectoutput "find" ["--copies", "1", "--and", "--not", "--copies", "2"] [sha1annexedfile]
|
git_annex_expectoutput "find" ["--copies", "1", "--and", "--not", "--copies", "2"] [sha1annexedfile]
|
||||||
git_annex_expectoutput "find" ["--inbackend", "SHA1"] [sha1annexedfile]
|
git_annex_expectoutput "find" ["--inbackend", "SHA1"] [sha1annexedfile]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue