examinekey: Added two new format variables: objectpath and objectpointer
This commit is contained in:
parent
c5141b469a
commit
12e32d1dee
4 changed files with 22 additions and 10 deletions
|
@ -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
|
* 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
|
is not known to the repository, to prevent confusion if the user has
|
||||||
copied it from some other repository.
|
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
|
-- Joey Hess <id@joeyh.name> Mon, 09 Nov 2020 15:15:20 -0400
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ module Command.ExamineKey where
|
||||||
import Command
|
import Command
|
||||||
import qualified Utility.Format
|
import qualified Utility.Format
|
||||||
import Command.Find (parseFormatOption, showFormatted, keyVars)
|
import Command.Find (parseFormatOption, showFormatted, keyVars)
|
||||||
|
import Annex.Link
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = noCommit $ noMessages $ dontCheck repoExists $
|
cmd = noCommit $ noMessages $ dontCheck repoExists $
|
||||||
|
@ -22,5 +23,10 @@ cmd = noCommit $ noMessages $ dontCheck repoExists $
|
||||||
run :: Maybe Utility.Format.Format -> SeekInput -> String -> Annex Bool
|
run :: Maybe Utility.Format.Format -> SeekInput -> String -> Annex Bool
|
||||||
run format _ p = do
|
run format _ p = do
|
||||||
let k = fromMaybe (giveup "bad key") $ deserializeKey p
|
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
|
return True
|
||||||
|
|
|
@ -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}';
|
use '${var;width}' ; to left-justify a variable, use '${var;-width}';
|
||||||
to escape unusual characters in a variable, use '${escaped_var}'
|
to escape unusual characters in a variable, use '${escaped_var}'
|
||||||
|
|
||||||
These variables are available for use in formats: key, backend,
|
To generate a path from the top of the repository to the git-annex
|
||||||
bytesize, humansize, keyname, hashdirlower, hashdirmixed, mtime (for
|
object for a key, use ${objectpath}. To generate the value of a
|
||||||
the mtime field of a WORM key).
|
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.
|
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,
|
Enable batch mode, in which a line containing a key is read from stdin,
|
||||||
the information about it is output to stdout, and repeat.
|
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
|
# SEE ALSO
|
||||||
|
|
||||||
[[git-annex]](1)
|
[[git-annex]](1)
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 3"""
|
||||||
|
date="2020-11-12T16:59:34Z"
|
||||||
|
content="""
|
||||||
|
Implemented examinekey ${objectpath} and ${objectpointer}.
|
||||||
|
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue