summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-09-18 20:14:18 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-09-18 20:14:18 -0400
commit1fc3ee24232059ae05ab18ed10bf151f86847ac1 (patch)
tree7cbfe5536143e09752e97da43d619b948fdeacc3
parentdd463a3100f21d72c35ca1af5b0f63f6296cf322 (diff)
add --in limit
-rw-r--r--GitAnnex.hs4
-rw-r--r--Limit.hs20
-rw-r--r--debian/changelog10
3 files changed, 31 insertions, 3 deletions
diff --git a/GitAnnex.hs b/GitAnnex.hs
index 68c7a1805..bcb30ff41 100644
--- a/GitAnnex.hs
+++ b/GitAnnex.hs
@@ -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 }
diff --git a/Limit.hs b/Limit.hs
index 91ea3453c..13df5f6c2 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -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
diff --git a/debian/changelog b/debian/changelog
index dff945c28..0b698bc66 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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