examinekey: Added two new format variables: objectpath and objectpointer
authorJoey Hess <joeyh@joeyh.name>
Thu, 12 Nov 2020 17:02:31 +0000 (13:02 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 12 Nov 2020 17:02:31 +0000 (13:02 -0400)
CHANGELOG
Command/ExamineKey.hs
doc/git-annex-examinekey.mdwn
doc/todo/calckey___91__--path__93___given_a_checksum_and_filename__63__/comment_3_4520660c0f66bd73158887f22586886e._comment [new file with mode: 0644]

index e12ce250fd638bae0bd92654d7479ec23f7df825..45c52c184b5bdf9a6fb458eed60d33a110748081 100644 (file)
--- 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 <id@joeyh.name>  Mon, 09 Nov 2020 15:15:20 -0400
 
index 2618e8b2ea767422be23c5c6f09212ed3ef00de9..5bca023b7d5f85d7249ab8efc1a31217d52edbfc 100644 (file)
@@ -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
index c66225ac2d555c2fc3b8288f659e660f323393d4..37f587af74fcf38c8498063b388770bf00fdc68e 100644 (file)
@@ -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 (file)
index 0000000..728d3e3
--- /dev/null
@@ -0,0 +1,7 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 3"""
+ date="2020-11-12T16:59:34Z"
+ content="""
+Implemented examinekey ${objectpath} and ${objectpointer}.
+"""]]