aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-09 15:34:47 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-09 15:34:47 -0400
commit82cf4fdc07b75d49c27604aef600efe97722d94b (patch)
treea15daa02f1c8a6470b99fd74b7b4dc523620483a
parenta186bb2d8d6b0eb3c0aad578c8c4a7254cef78e2 (diff)
contentlocationn: New plumbing command.
-rw-r--r--Annex/Content.hs1
-rw-r--r--CmdLine/GitAnnex.hs2
-rw-r--r--Command/ContentLocation.hs32
-rw-r--r--debian/changelog1
-rw-r--r--doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load.mdwn1
-rw-r--r--doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load/comment_3_6430c915dd2969bda4070fa4ba01a935._comment14
-rw-r--r--doc/git-annex-contentlocation.mdwn27
-rw-r--r--doc/git-annex.mdwn6
8 files changed, 84 insertions, 0 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index 310c43daf..17050224d 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -9,6 +9,7 @@
module Annex.Content (
inAnnex,
+ inAnnex',
inAnnexSafe,
inAnnexCheck,
lockContent,
diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs
index 6aeefda05..fde4e2d08 100644
--- a/CmdLine/GitAnnex.hs
+++ b/CmdLine/GitAnnex.hs
@@ -22,6 +22,7 @@ import qualified Command.Move
import qualified Command.Copy
import qualified Command.Get
import qualified Command.LookupKey
+import qualified Command.ContentLocation
import qualified Command.ExamineKey
import qualified Command.FromKey
import qualified Command.RegisterUrl
@@ -152,6 +153,7 @@ cmds = concat
, Command.Ungroup.cmd
, Command.Vicfg.cmd
, Command.LookupKey.cmd
+ , Command.ContentLocation.cmd
, Command.ExamineKey.cmd
, Command.FromKey.cmd
, Command.RegisterUrl.cmd
diff --git a/Command/ContentLocation.hs b/Command/ContentLocation.hs
new file mode 100644
index 000000000..555f909cd
--- /dev/null
+++ b/Command/ContentLocation.hs
@@ -0,0 +1,32 @@
+{- git-annex command
+ -
+ - Copyright 2015 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Command.ContentLocation where
+
+import Common.Annex
+import Command
+import Annex.Content
+import Types.Key
+
+cmd :: [Command]
+cmd = [noCommit $ noMessages $
+ command "contentlocation" (paramRepeating paramKey) seek
+ SectionPlumbing "looks up content for a key"]
+
+seek :: CommandSeek
+seek = withKeys start
+
+start :: Key -> CommandStart
+start k = do
+ liftIO . maybe exitFailure putStrLn
+ =<< inAnnex' (pure True) Nothing check k
+ stop
+ where
+ check f = ifM (liftIO (doesFileExist f))
+ ( return (Just f)
+ , return Nothing
+ )
diff --git a/debian/changelog b/debian/changelog
index b506241ac..0958e7dc5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,7 @@ git-annex (5.20150409) unstable; urgency=medium
with the current repository, the new repository's remote path
was set to "." rather than the path to the current repository.
This was a reversion caused by the relative path changes in 5.20150113.
+ * contentlocationn: New plumbing command.
-- Joey Hess <id@joeyh.name> Thu, 09 Apr 2015 15:06:38 -0400
diff --git a/doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load.mdwn b/doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load.mdwn
index df42a4906..7f9ca28f6 100644
--- a/doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load.mdwn
+++ b/doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load.mdwn
@@ -2,3 +2,4 @@
Current layout is DIRHASH (of two levels) /KEY/KEY, so I would need to hardcode having that KEY directory. It might be nice to either make DIRHASH to return full hash directory (but it might break existing special remotes), or supplement with e.g. DIRHASHFULL which would return all the levels necessary to reach the KEY file
+> [[done]] --[[Joey]]
diff --git a/doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load/comment_3_6430c915dd2969bda4070fa4ba01a935._comment b/doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load/comment_3_6430c915dd2969bda4070fa4ba01a935._comment
new file mode 100644
index 000000000..b6d24563a
--- /dev/null
+++ b/doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load/comment_3_6430c915dd2969bda4070fa4ba01a935._comment
@@ -0,0 +1,14 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 3"""
+ date="2015-04-09T19:08:40Z"
+ content="""
+I've added a contentlocation command
+
+I'd expect an external command to not be much slower than using the pipe
+for this. It does not need to spin up any git commands etc to get the
+content location. Also, you can pass it multiple keys to query at one time
+if necessary.
+
+I guess we'll see if this is too slow and can revisit it if so..
+"""]]
diff --git a/doc/git-annex-contentlocation.mdwn b/doc/git-annex-contentlocation.mdwn
new file mode 100644
index 000000000..128622bc8
--- /dev/null
+++ b/doc/git-annex-contentlocation.mdwn
@@ -0,0 +1,27 @@
+# NAME
+
+git-annex contentlocation - looks up content for a key
+
+# SYNOPSIS
+
+git annex contentlocation `[key ...]`
+
+# DESCRIPTION
+
+This plumbing-level command looks up filename used to store the content
+of a key. The filename is output to stdout. If the key's content is not
+present in the local repository, nothing is output, and it exits nonzero.
+
+Note that in direct mode, the file will typically be in the git work
+tree, and while its content should correspond to the key, the file
+could become modified at any time after git-annex checks it.
+
+# SEE ALSO
+
+[[git-annex]](1)
+
+# AUTHOR
+
+Joey Hess <id@joeyh.name>
+
+Warning: Automatically converted into a man page by mdwn2man. Edit with care.
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 11fbc6e01..6fd10aed0 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -513,6 +513,12 @@ subdirectories).
See [[git-annex-lookupkey]](1) for details.
+* `contentlocation [key ..]`
+
+ Looks up location of annexed content for a key.
+
+ See [[git-annex-contentlocation]](1) for details.
+
* `examinekey [key ...]`
Print information that can be determined purely by looking at the key.