Home Explore Blog CI



git

5th chunk of `Documentation/git-for-each-ref.adoc`
584fa59f39d8488a76af4b3b44b2c4f0a35efa37f78b50090000000100000cd4
 and tag objects, the header
field names (`tree`, `parent`, `object`, `type`, and `tag`) can
be used to specify the value in the header field.
Fields `tree` and `parent` can also be used with modifier `:short` and
`:short=<length>` just like `objectname`.

For commit and tag objects, the special `creatordate` and `creator`
fields will correspond to the appropriate date or name-email-date tuple
from the `committer` or `tagger` fields depending on the object type.
These are intended for working on a mix of annotated and lightweight tags.

For tag objects, a `fieldname` prefixed with an asterisk (`*`) expands to
the `fieldname` value of the peeled object, rather than that of the tag
object itself.

Fields that have name-email-date tuple as its value (`author`,
`committer`, and `tagger`) can be suffixed with `name`, `email`,
and `date` to extract the named component.  For email fields (`authoremail`,
`committeremail` and `taggeremail`), `:trim` can be appended to get the email
without angle brackets, and `:localpart` to get the part before the `@` symbol
out of the trimmed email. In addition to these, the `:mailmap` option and the
corresponding `:mailmap,trim` and `:mailmap,localpart` can be used (order does
not matter) to get values of the name and email according to the .mailmap file
or according to the file set in the mailmap.file or mailmap.blob configuration
variable (see linkgit:gitmailmap[5]).

The raw data in an object is `raw`.

raw:size::
	The raw data size of the object.

Note that `--format=%(raw)` can not be used with `--python`, `--shell`, `--tcl`,
because such language may not support arbitrary binary data in their string
variable type.

The message in a commit or a tag object is `contents`, from which
`contents:<part>` can be used to extract various parts out of:

contents:size::
	The size in bytes of the commit or tag message.

contents:subject::
	The first paragraph of the message, which typically is a
	single line, is taken as the "subject" of the commit or the
	tag message.
	Instead of `contents:subject`, field `subject` can also be used to
	obtain same results. `:sanitize` can be appended to `subject` for
	subject line suitable for filename.

contents:body::
	The remainder of the commit or the tag message that follows
	the "subject".

contents:signature::
	The optional GPG signature of the tag.

contents:lines=N::
	The first `N` lines of the message.

Additionally, the trailers as interpreted by linkgit:git-interpret-trailers[1]
are obtained as `trailers[:options]` (or by using the historical alias
`contents:trailers[:options]`). For valid [:option] values see `trailers`
section of linkgit:git-log[1].

For sorting purposes, fields with numeric values sort in numeric order
(`objectsize`, `authordate`, `committerdate`, `creatordate`, `taggerdate`).
All other fields are used to sort in their byte-value order.

There is also an option to sort by versions, this can be done by using
the fieldname `version:refname` or its alias `v:refname`.

In any case, a field name that refers to a field inapplicable to
the object referred by the ref does not cause an error.  It
returns an empty string instead.

As a special case for the date-type fields, you may specify a format for the
date by adding `:` followed by date format

Title: Git Format Specifiers for Objects and Messages
Summary
Git provides various format specifiers to extract information from objects, such as commits and tags, and their messages. These specifiers allow for the extraction of specific data, including header fields, creator information, and message components. Additional options enable sorting, formatting of date fields, and the use of mail maps to resolve author and committer email addresses.