diff --git a/CHANGELOG b/CHANGELOG index e12ce250fd..45c52c184b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ git-annex (8.20201104) UNRELEASED; urgency=medium * Warn when adding a annex symlink or pointer file that uses a key that is not known to the repository, to prevent confusion if the user has copied it from some other repository. + * examinekey: Added two new format variables: objectpath and objectpointer -- Joey Hess Mon, 09 Nov 2020 15:15:20 -0400 diff --git a/Command/ExamineKey.hs b/Command/ExamineKey.hs index 2618e8b2ea..5bca023b7d 100644 --- a/Command/ExamineKey.hs +++ b/Command/ExamineKey.hs @@ -10,6 +10,7 @@ module Command.ExamineKey where import Command import qualified Utility.Format import Command.Find (parseFormatOption, showFormatted, keyVars) +import Annex.Link cmd :: Command cmd = noCommit $ noMessages $ dontCheck repoExists $ @@ -22,5 +23,10 @@ cmd = noCommit $ noMessages $ dontCheck repoExists $ run :: Maybe Utility.Format.Format -> SeekInput -> String -> Annex Bool run format _ p = do let k = fromMaybe (giveup "bad key") $ deserializeKey p - showFormatted format (serializeKey' k) (keyVars k) + objectpath <- calcRepo $ gitAnnexLocation k + let objectpointer = formatPointer k + showFormatted format (serializeKey' k) $ + [ ("objectpath", fromRawFilePath objectpath) + , ("objectpointer", fromRawFilePath objectpointer) + ] ++ keyVars k return True diff --git a/doc/git-annex-examinekey.mdwn b/doc/git-annex-examinekey.mdwn index c66225ac2d..37f587af74 100644 --- a/doc/git-annex-examinekey.mdwn +++ b/doc/git-annex-examinekey.mdwn @@ -22,9 +22,13 @@ that can be determined purely by looking at the key. use '${var;width}' ; to left-justify a variable, use '${var;-width}'; to escape unusual characters in a variable, use '${escaped_var}' - These variables are available for use in formats: key, backend, - bytesize, humansize, keyname, hashdirlower, hashdirmixed, mtime (for - the mtime field of a WORM key). + To generate a path from the top of the repository to the git-annex + object for a key, use ${objectpath}. To generate the value of a + git-annex pointer file for a key, use ${objectpointer}. + + These variables are also available for use in formats: ${key}, ${backend}, + ${bytesize}, ${humansize}, ${keyname}, ${hashdirlower}, ${hashdirmixed}, + ${mtime} (for the mtime field of a WORM key). Also, '\\n' is a newline, '\\000' is a NULL, etc. @@ -43,12 +47,6 @@ that can be determined purely by looking at the key. Enable batch mode, in which a line containing a key is read from stdin, the information about it is output to stdout, and repeat. -# EXAMPLES - -The location where the content of a key is stored can be looked up by running: - - git annex examinekey $KEY --format='.git/annex/objects/${hashdirmixed}${key}/${key}' - # SEE ALSO [[git-annex]](1) diff --git a/doc/todo/calckey___91__--path__93___given_a_checksum_and_filename__63__/comment_3_4520660c0f66bd73158887f22586886e._comment b/doc/todo/calckey___91__--path__93___given_a_checksum_and_filename__63__/comment_3_4520660c0f66bd73158887f22586886e._comment new file mode 100644 index 0000000000..728d3e3f5e --- /dev/null +++ b/doc/todo/calckey___91__--path__93___given_a_checksum_and_filename__63__/comment_3_4520660c0f66bd73158887f22586886e._comment @@ -0,0 +1,7 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 3""" + date="2020-11-12T16:59:34Z" + content=""" +Implemented examinekey ${objectpath} and ${objectpointer}. +"""]]