2015-03-25 16:09:49 +00:00
|
|
|
# NAME
|
|
|
|
|
|
|
|
git-annex metadata - sets or gets metadata of a file
|
|
|
|
|
|
|
|
# SYNOPSIS
|
|
|
|
|
|
|
|
git annex metadata `[path ...]`
|
|
|
|
|
|
|
|
# DESCRIPTION
|
|
|
|
|
|
|
|
The content of an annexed file can have any number of metadata fields
|
|
|
|
attached to it to describe it. Each metadata field can in turn
|
|
|
|
have any number of values.
|
|
|
|
|
|
|
|
This command can be used to set metadata, or show the currently set
|
|
|
|
metadata.
|
|
|
|
|
|
|
|
When run without any -s or -t parameters, displays the current metadata.
|
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
Each metadata field has its own "field-lastchanged" metadata, which
|
|
|
|
contains the date the field was last changed. Unlike other metadata,
|
|
|
|
this cannot be directly modified by this command. It is updated
|
|
|
|
automatically.
|
|
|
|
|
2019-05-03 15:37:41 +00:00
|
|
|
Note that the metadata is attached to git-annex key corresponding to the
|
|
|
|
content of a file, not to a particular filename on a particular git branch.
|
2018-10-02 16:53:53 +00:00
|
|
|
All files with the same key share the same metadata, which is
|
2019-05-03 15:37:41 +00:00
|
|
|
stored in the git-annex branch. If a file is modified, the metadata
|
|
|
|
of the previous version will be copied to the new key when git-annex adds
|
|
|
|
the modified file.
|
2018-09-25 17:10:34 +00:00
|
|
|
|
2015-03-25 16:09:49 +00:00
|
|
|
# OPTIONS
|
|
|
|
|
2016-02-29 17:00:46 +00:00
|
|
|
* `-g field` / `--get field`
|
2015-03-25 16:09:49 +00:00
|
|
|
|
|
|
|
Get the value(s) of a single field.
|
|
|
|
|
|
|
|
The values will be output one per line, with no other output, so
|
|
|
|
this is suitable for use in a script.
|
|
|
|
|
2016-02-29 17:00:46 +00:00
|
|
|
* `-s field=value` / `--set field=value`
|
2015-03-25 16:09:49 +00:00
|
|
|
|
|
|
|
Set a field's value, removing any old values.
|
|
|
|
|
2016-02-29 17:00:46 +00:00
|
|
|
* `-s field+=value` / `--set field+=value`
|
2015-03-25 16:09:49 +00:00
|
|
|
|
|
|
|
Add an additional value, preserving any old values.
|
|
|
|
|
2016-02-29 17:00:46 +00:00
|
|
|
* `-s field?=value` / `--set field?=value`
|
2015-03-25 16:09:49 +00:00
|
|
|
|
2016-02-29 17:00:46 +00:00
|
|
|
Set a value, but only if the field does not already have a value set.
|
2015-03-25 16:09:49 +00:00
|
|
|
|
2016-02-29 17:00:46 +00:00
|
|
|
* `-s field-=value` / `--set field-=value`
|
2015-03-25 16:09:49 +00:00
|
|
|
|
2016-02-29 17:00:46 +00:00
|
|
|
Remove a value from a field, leaving any other values that the field has
|
|
|
|
set.
|
|
|
|
|
|
|
|
* `-r field` / `--remove field`
|
|
|
|
|
|
|
|
Remove all current values of the field.
|
|
|
|
|
|
|
|
* `-t tag` / `--tag tag`
|
2015-03-25 16:09:49 +00:00
|
|
|
|
|
|
|
Set a tag. Note that a tag is just a value of the "tag" field.
|
|
|
|
|
2016-02-29 17:00:46 +00:00
|
|
|
* `-u tag` / `--unset tag`
|
2015-03-25 16:09:49 +00:00
|
|
|
|
|
|
|
Unset a tag.
|
|
|
|
|
2017-09-28 16:36:10 +00:00
|
|
|
* `--remove-all`
|
|
|
|
|
|
|
|
Remove all metadata from the specified files.
|
|
|
|
|
|
|
|
When a file is modified and the new version added, git-annex will copy
|
|
|
|
over the metadata from the old version of the file. In situations where
|
|
|
|
you don't want that copied metadata, you can use this option to remove
|
|
|
|
it.
|
|
|
|
|
2015-03-25 16:09:49 +00:00
|
|
|
* `--force`
|
|
|
|
|
|
|
|
By default, `git annex metadata` refuses to recursively set metadata
|
|
|
|
throughout the files in a directory. This option enables such recursive
|
|
|
|
setting.
|
|
|
|
|
|
|
|
* file matching options
|
|
|
|
|
|
|
|
The [[git-annex-matching-options]](1)
|
|
|
|
can be used to specify files to act on.
|
|
|
|
|
2018-04-04 03:12:04 +00:00
|
|
|
* `--all` `-A`
|
2016-07-27 14:46:25 +00:00
|
|
|
|
|
|
|
Specify instead of a file to get/set metadata on all known keys.
|
|
|
|
|
|
|
|
* `--branch=ref`
|
|
|
|
|
|
|
|
Specify instead of a file to get/set metadata on all files in the
|
|
|
|
specified branch or treeish.
|
|
|
|
|
|
|
|
* `--unused`
|
|
|
|
|
|
|
|
Specify instead of a file to get/set metadata on
|
|
|
|
files found by last run of git-annex unused.
|
|
|
|
|
|
|
|
* `--key=keyname`
|
|
|
|
|
|
|
|
Specify instead of a file to get/set metadata of the specified key.
|
|
|
|
|
2015-03-25 16:09:49 +00:00
|
|
|
* `--json`
|
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
Enable JSON output (and input). Each line is a JSON object.
|
2015-03-25 16:09:49 +00:00
|
|
|
|
2016-07-26 18:53:00 +00:00
|
|
|
The format of the JSON objects changed in git-annex version 6.20160726.
|
|
|
|
|
|
|
|
Example of the new format:
|
|
|
|
|
|
|
|
{"command":"metadata","file":"foo","key":"...","fields":{"author":["bar"],...},"note":"...","success":true}
|
|
|
|
|
|
|
|
Example of the old format, which lacks the inner fields object:
|
|
|
|
|
|
|
|
{"command":"metadata","file":"foo","key":"...","author":["bar"],...,"note":"...","success":true}
|
|
|
|
|
2018-02-19 18:28:17 +00:00
|
|
|
* `--json-error-messages`
|
|
|
|
|
2018-02-19 19:33:59 +00:00
|
|
|
Messages that would normally be output to standard error are included in
|
|
|
|
the json instead.
|
2018-02-19 18:28:17 +00:00
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
* `--batch`
|
2015-04-21 20:31:00 +00:00
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
Enables batch mode, which can be used to both get, store, and unset
|
|
|
|
metadata for multiple files or keys.
|
2015-04-21 20:31:00 +00:00
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
Batch currently only supports JSON input. So, you must
|
|
|
|
enable `--json` along with `--batch`.
|
--branch, stage 1
Added --branch option to copy, drop, fsck, get, metadata, mirror, move, and
whereis commands. This option makes git-annex operate on files that are
included in a specified branch (or other treeish).
The names of the files from the branch that are being operated on are not
displayed yet; only the keys. Displaying the filenames will need changes
to every affected command.
Also, note that --branch can be specified repeatedly. This is not really
documented, but seemed worth supporting, especially since we may later want
the ability to operate on all branches matching a refspec. However, when
operating on two branches that contain the same key, that key will be
operated on twice.
2016-07-20 16:05:22 +00:00
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
In batch mode, git-annex reads lines from stdin, which contain
|
|
|
|
JSON objects. It replies to each input with an output JSON object.
|
--branch, stage 1
Added --branch option to copy, drop, fsck, get, metadata, mirror, move, and
whereis commands. This option makes git-annex operate on files that are
included in a specified branch (or other treeish).
The names of the files from the branch that are being operated on are not
displayed yet; only the keys. Displaying the filenames will need changes
to every affected command.
Also, note that --branch can be specified repeatedly. This is not really
documented, but seemed worth supporting, especially since we may later want
the ability to operate on all branches matching a refspec. However, when
operating on two branches that contain the same key, that key will be
operated on twice.
2016-07-20 16:05:22 +00:00
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
The format of the JSON sent to git-annex can be the same as the JSON that
|
|
|
|
it outputs. Or, a simplified version. Only the "file" (or "key") field
|
|
|
|
is actually necessary.
|
2015-04-21 20:31:00 +00:00
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
For example, to get the current metadata of file foo:
|
2015-04-21 20:31:00 +00:00
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
{"file":"foo"}
|
2015-04-21 20:31:00 +00:00
|
|
|
|
2016-07-27 14:46:25 +00:00
|
|
|
To get the current metadata of the key k:
|
|
|
|
|
|
|
|
{"key":"k"}
|
|
|
|
|
|
|
|
Any metadata fields included in the JSON object will be stored,
|
|
|
|
replacing whatever values the fields had before.
|
|
|
|
To unset a field, include it with an empty list of values.
|
|
|
|
|
|
|
|
To change the author of file foo to bar:
|
|
|
|
|
|
|
|
{"file":"foo","fields":{"author":["bar"]}}
|
|
|
|
|
|
|
|
To remove the author of file foo:
|
|
|
|
|
|
|
|
{"file":"foo","fields":{"author":[]}}
|
2015-04-21 20:31:00 +00:00
|
|
|
|
make --batch honor matching options
When --batch is used with matching options like --in, --metadata, etc, only
operate on the provided files when they match those options. Otherwise, a
blank line is output in the batch protocol.
Affected commands: find, add, whereis, drop, copy, move, get
In the case of find, the documentation for --batch already said it honored
the matching options. The docs for the rest didn't, but it makes sense to
have them honor them. While this is a behavior change, why specify the
matching options with --batch if you didn't want them to apply?
Note that the batch output for all of the affected commands could
already output a blank line in other cases, so batch users should
already be prepared to deal with it.
git-annex metadata didn't seem worth making support the matching options,
since all it does is output metadata or set metadata, the use cases for
using it in combination with the martching options seem small. Made it
refuse to run when they're combined, leaving open the possibility for later
support if a use case develops.
This commit was sponsored by Brett Eisenberg on Patreon.
2018-08-08 16:03:30 +00:00
|
|
|
Note that file matching options do not affect the files that are
|
|
|
|
processed when in batch mode.
|
|
|
|
|
2021-05-10 19:00:13 +00:00
|
|
|
* Also the [[git-annex-common-options]](1) can be used.
|
|
|
|
|
2015-03-25 16:09:49 +00:00
|
|
|
# EXAMPLES
|
|
|
|
|
|
|
|
To set some tags on a file and also its author:
|
|
|
|
|
|
|
|
git annex metadata annexscreencast.ogv -t video -t screencast -s author+=Alice
|
|
|
|
|
|
|
|
# SEE ALSO
|
|
|
|
|
|
|
|
[[git-annex]](1)
|
|
|
|
|
2015-05-29 16:12:55 +00:00
|
|
|
[[git-annex-view]](1)
|
|
|
|
|
2015-03-25 16:09:49 +00:00
|
|
|
# AUTHOR
|
|
|
|
|
|
|
|
Joey Hess <id@joeyh.name>
|
|
|
|
|
|
|
|
Warning: Automatically converted into a man page by mdwn2man. Edit with care.
|