* 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
import Command
import qualified Utility.Format
import Command.Find (parseFormatOption, showFormatted, keyVars)
+import Annex.Link
cmd :: Command
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
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.
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)