add --in limit
This commit is contained in:
parent
dd463a3100
commit
1fc3ee2423
3 changed files with 31 additions and 3 deletions
|
@ -108,8 +108,10 @@ options = commonOptions ++
|
||||||
"override trust setting to untrusted"
|
"override trust setting to untrusted"
|
||||||
, Option ['c'] ["config"] (ReqArg setgitconfig "NAME=VALUE")
|
, Option ['c'] ["config"] (ReqArg setgitconfig "NAME=VALUE")
|
||||||
"override git configuration setting"
|
"override git configuration setting"
|
||||||
, Option ['x'] ["exclude"] (ReqArg (Limit.exclude) paramGlob)
|
, Option ['x'] ["exclude"] (ReqArg (Limit.addExclude) paramGlob)
|
||||||
"skip files matching the glob pattern"
|
"skip files matching the glob pattern"
|
||||||
|
, Option ['i'] ["in"] (ReqArg (Limit.addIn) paramRemote)
|
||||||
|
"skip files not present in a remote"
|
||||||
] ++ matcherOptions
|
] ++ matcherOptions
|
||||||
where
|
where
|
||||||
setto v = Annex.changeState $ \s -> s { Annex.toremote = Just v }
|
setto v = Annex.changeState $ \s -> s { Annex.toremote = Just v }
|
||||||
|
|
20
Limit.hs
20
Limit.hs
|
@ -14,6 +14,9 @@ import Data.Maybe
|
||||||
|
|
||||||
import Annex
|
import Annex
|
||||||
import qualified Utility.Matcher
|
import qualified Utility.Matcher
|
||||||
|
import qualified Remote
|
||||||
|
import qualified Backend
|
||||||
|
import LocationLog
|
||||||
|
|
||||||
type Limit = Utility.Matcher.Token (FilePath -> Annex Bool)
|
type Limit = Utility.Matcher.Token (FilePath -> Annex Bool)
|
||||||
|
|
||||||
|
@ -51,9 +54,22 @@ token :: String -> Annex ()
|
||||||
token = add . Utility.Matcher.Token
|
token = add . Utility.Matcher.Token
|
||||||
|
|
||||||
{- Add a limit to skip files that do not match the glob. -}
|
{- Add a limit to skip files that do not match the glob. -}
|
||||||
exclude :: String -> Annex ()
|
addExclude :: String -> Annex ()
|
||||||
exclude glob = addlimit $ return . notExcluded
|
addExclude glob = addlimit $ return . notExcluded
|
||||||
where
|
where
|
||||||
notExcluded f = isNothing $ match cregex f []
|
notExcluded f = isNothing $ match cregex f []
|
||||||
cregex = compile regex []
|
cregex = compile regex []
|
||||||
regex = '^':wildToRegex glob
|
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
10
debian/changelog
vendored
|
@ -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
|
git-annex (3.20110915) unstable; urgency=low
|
||||||
|
|
||||||
* whereis: Show untrusted locations separately and do not include in
|
* whereis: Show untrusted locations separately and do not include in
|
||||||
|
|
Loading…
Reference in a new issue