summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Annex/CatFile.hs2
-rw-r--r--Command/LookupKey.hs26
-rw-r--r--GitAnnex.hs2
-rw-r--r--debian/changelog1
-rw-r--r--doc/git-annex.mdwn7
5 files changed, 37 insertions, 1 deletions
diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs
index 812d032c6..54a4d1099 100644
--- a/Annex/CatFile.hs
+++ b/Annex/CatFile.hs
@@ -119,7 +119,7 @@ catKeyChecked needhead ref@(Ref r) =
- For command-line git-annex use, that doesn't matter. It's perfectly
- reasonable for things staged in the index after the currently running
- git-annex process to not be noticed by it. However, we do want to see
- - what's in the index, since it may have uncommitted changes not in HEAD>
+ - what's in the index, since it may have uncommitted changes not in HEAD
-
- For the assistant, this is much more of a problem, since it commits
- files and then needs to be able to immediately look up their keys.
diff --git a/Command/LookupKey.hs b/Command/LookupKey.hs
new file mode 100644
index 000000000..7964213fe
--- /dev/null
+++ b/Command/LookupKey.hs
@@ -0,0 +1,26 @@
+{- git-annex command
+ -
+ - Copyright 2013 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Command.LookupKey where
+
+import Common.Annex
+import Command
+import Annex.CatFile
+import Types.Key
+
+def :: [Command]
+def = [notBareRepo $
+ command "lookupkey" (paramRepeating paramFile) seek
+ SectionPlumbing "looks up key used for file"]
+
+seek :: [CommandSeek]
+seek = [withStrings start]
+
+start :: String -> CommandStart
+start file = do
+ liftIO . maybe exitFailure (putStrLn . key2file) =<< catKeyFile file
+ stop
diff --git a/GitAnnex.hs b/GitAnnex.hs
index 5b69a2d9d..8ea0c9569 100644
--- a/GitAnnex.hs
+++ b/GitAnnex.hs
@@ -20,6 +20,7 @@ import qualified Command.Drop
import qualified Command.Move
import qualified Command.Copy
import qualified Command.Get
+import qualified Command.LookupKey
import qualified Command.FromKey
import qualified Command.DropKey
import qualified Command.TransferKey
@@ -124,6 +125,7 @@ cmds = concat
, Command.Schedule.def
, Command.Ungroup.def
, Command.Vicfg.def
+ , Command.LookupKey.def
, Command.FromKey.def
, Command.DropKey.def
, Command.TransferKey.def
diff --git a/debian/changelog b/debian/changelog
index 128a161f6..f39df1f8d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
git-annex (5.20131214) UNRELEASED; urgency=low
* Fix test suite to cover lock --force change.
+ * Add plumbing-level lookupkey command.
-- Joey Hess <joeyh@debian.org> Sun, 15 Dec 2013 13:32:49 -0400
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 4602849c2..5d61b8b40 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -727,6 +727,13 @@ subdirectories).
point to annexed content. Also handles injecting changes to unlocked
files into the annex.
+* `lookupkey [file ...]`
+
+ This plumbing-level command looks up the key used for a file in the
+ index. The key is output to stdout. If there is no key (because
+ the file is not added to git, or is not a git-annex managed file),
+ nothing is output, and it exits nonzero.
+
* `fromkey key file`
This plumbing-level command can be used to manually set up a file