add --in limit

This commit is contained in:
Joey Hess 2011-09-18 20:14:18 -04:00
parent dd463a3100
commit 1fc3ee2423
3 changed files with 31 additions and 3 deletions

View file

@ -108,8 +108,10 @@ options = commonOptions ++
"override trust setting to untrusted"
, Option ['c'] ["config"] (ReqArg setgitconfig "NAME=VALUE")
"override git configuration setting"
, Option ['x'] ["exclude"] (ReqArg (Limit.exclude) paramGlob)
, Option ['x'] ["exclude"] (ReqArg (Limit.addExclude) paramGlob)
"skip files matching the glob pattern"
, Option ['i'] ["in"] (ReqArg (Limit.addIn) paramRemote)
"skip files not present in a remote"
] ++ matcherOptions
where
setto v = Annex.changeState $ \s -> s { Annex.toremote = Just v }

View file

@ -14,6 +14,9 @@ import Data.Maybe
import Annex
import qualified Utility.Matcher
import qualified Remote
import qualified Backend
import LocationLog
type Limit = Utility.Matcher.Token (FilePath -> Annex Bool)
@ -51,9 +54,22 @@ token :: String -> Annex ()
token = add . Utility.Matcher.Token
{- Add a limit to skip files that do not match the glob. -}
exclude :: String -> Annex ()
exclude glob = addlimit $ return . notExcluded
addExclude :: String -> Annex ()
addExclude glob = addlimit $ return . notExcluded
where
notExcluded f = isNothing $ match cregex f []
cregex = compile regex []
regex = '^':wildToRegex glob
{- Adds a limit to skip files not believed to be present
- on a specfied remote. -}
addIn :: String -> Annex ()
addIn name = do
u <- Remote.nameToUUID name
addlimit $ check u
where
check u f = Backend.lookupFile f >>= handle u
handle _ Nothing = return False
handle u (Just (key, _)) = do
us <- keyLocations key
return $ u `elem` us

10
debian/changelog vendored
View file

@ -1,3 +1,13 @@
git-annex (3.20110916) UNRELEASED; urgency=low
* --in can be used to make git-annex only operate on files
believed to be present in a given repository.
* Arbitrarily complex expressions can be built to limit the files git-annex
operates on, by combining the options --not --and --or -( and -)
Example: git annex get --exclude '*.mp3' --and --not -( --in usbdrive --or --in archive -)
-- Joey Hess <joeyh@debian.org> Sun, 18 Sep 2011 18:25:51 -0400
git-annex (3.20110915) unstable; urgency=low
* whereis: Show untrusted locations separately and do not include in