aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-03-20 11:22:27 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-03-20 11:22:27 -0400
commit82ee689db44ebabca2ecd093f9da40ef46fbc067 (patch)
tree74985d178621fabcc3d450c15054397afec9b84d
parent6c43dd47ff2f1b8e21480b3b4b1a131ef283444b (diff)
readpresentkey: New plumbing command for checking location log.
-rw-r--r--CmdLine/GitAnnex.hs2
-rw-r--r--Command/ReadPresentKey.hs30
-rw-r--r--debian/changelog6
-rw-r--r--doc/git-annex.mdwn10
4 files changed, 47 insertions, 1 deletions
diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs
index f25af34b3..f2953da36 100644
--- a/CmdLine/GitAnnex.hs
+++ b/CmdLine/GitAnnex.hs
@@ -29,6 +29,7 @@ import qualified Command.DropKey
import qualified Command.TransferKey
import qualified Command.TransferKeys
import qualified Command.SetPresentKey
+import qualified Command.ReadPresentKey
import qualified Command.ReKey
import qualified Command.MetaData
import qualified Command.View
@@ -156,6 +157,7 @@ cmds = concat
, Command.TransferKey.cmd
, Command.TransferKeys.cmd
, Command.SetPresentKey.cmd
+ , Command.ReadPresentKey.cmd
, Command.ReKey.cmd
, Command.MetaData.cmd
, Command.View.cmd
diff --git a/Command/ReadPresentKey.hs b/Command/ReadPresentKey.hs
new file mode 100644
index 000000000..8125ddf7e
--- /dev/null
+++ b/Command/ReadPresentKey.hs
@@ -0,0 +1,30 @@
+{- git-annex command
+ -
+ - Copyright 2015 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Command.ReadPresentKey where
+
+import Common.Annex
+import Command
+import Logs.Location
+import Types.Key
+
+cmd :: [Command]
+cmd = [noCommit $ command "readpresentkey" (paramPair paramKey paramUUID) seek
+ SectionPlumbing "read records of where key is present"]
+
+seek :: CommandSeek
+seek = withWords start
+
+start :: [String] -> CommandStart
+start (ks:us:[]) = do
+ ls <- loggedLocations k
+ if toUUID us `elem` ls
+ then liftIO exitSuccess
+ else liftIO exitFailure
+ where
+ k = fromMaybe (error "bad key") (file2key ks)
+start _ = error "Wrong number of parameters"
diff --git a/debian/changelog b/debian/changelog
index 80df2ca72..d3c3b048a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+git-annex (5.20150318) UNRELEASED; urgency=medium
+
+ * readpresentkey: New plumbing command for checking location log.
+
+ -- Joey Hess <id@joeyh.name> Thu, 19 Mar 2015 17:05:32 -0400
+
git-annex (5.20150317) unstable; urgency=medium
* fsck: Incremental fsck uses sqlite to store its records, instead
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index c33633e03..c0bf08e0b 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -1000,7 +1000,15 @@ subdirectories).
* `setpresentkey key uuid [1|0]`
This plumbing-level command changes git-annex's records about whether
- the specified key is present in a remote with the specified uuid.
+ the specified key's content is present in a remote with the specified uuid.
+
+* `readpresentkey key uuid`
+
+ This plumbing-level command reads git-annex's records about whether
+ the specified key's content is present in the remote with the speficied
+ uuid.
+
+ It exits 0 if the key is recorded to be present and 1 if not.
* `rekey [file key ...]`