From ce0a82f4937a0312ed47e340bdb072bfe06a9961 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 9 Apr 2015 15:34:47 -0400 Subject: [PATCH] contentlocationn: New plumbing command. --- Annex/Content.hs | 1 + CmdLine/GitAnnex.hs | 2 ++ Command/ContentLocation.hs | 32 +++++++++++++++++++ debian/changelog | 1 + ..._outputs_full_DIRHASH_to_the_key_load.mdwn | 1 + ..._6430c915dd2969bda4070fa4ba01a935._comment | 14 ++++++++ doc/git-annex-contentlocation.mdwn | 27 ++++++++++++++++ doc/git-annex.mdwn | 6 ++++ 8 files changed, 84 insertions(+) create mode 100644 Command/ContentLocation.hs create mode 100644 doc/bugs/for_custom_remotes_provide_enhanced_DIRHASH_which_outputs_full_DIRHASH_to_the_key_load/comment_3_6430c915dd2969bda4070fa4ba01a935._comment create mode 100644 doc/git-annex-contentlocation.mdwn diff --git a/Annex/Content.hs b/Annex/Content.hs index 310c43daf8..17050224dc 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 6aeefda054..fde4e2d08b 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 0000000000..555f909cdf --- /dev/null +++ b/Command/ContentLocation.hs @@ -0,0 +1,32 @@ +{- git-annex command + - + - Copyright 2015 Joey Hess + - + - 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 b506241acd..0958e7dc55 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 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 df42a49066..7f9ca28f63 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 0000000000..b6d24563aa --- /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 0000000000..128622bc8b --- /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 + +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 11fbc6e017..6fd10aed00 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.