Merge branch 'la/doc-interpret-trailers'
Doc update. * la/doc-interpret-trailers: doc: trailer: add more examples in DESCRIPTION doc: trailer: mention 'key' in DESCRIPTION doc: trailer.<token>.command: emphasize deprecation doc: trailer: use angle brackets for <token> and <value> doc: trailer: remove redundant phrasing doc: trailer: examples: avoid the word "message" by itself doc: trailer: drop "commit message part" phrasing doc: trailer: swap verb order doc: trailer: fix grammar
This commit is contained in:
@ -14,21 +14,38 @@ SYNOPSIS
|
|||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
Help parsing or adding 'trailers' lines, that look similar to RFC 822 e-mail
|
Add or parse 'trailer' lines that look similar to RFC 822 e-mail
|
||||||
headers, at the end of the otherwise free-form part of a commit
|
headers, at the end of the otherwise free-form part of a commit
|
||||||
message.
|
message. For example, in the following commit message
|
||||||
|
|
||||||
This command reads some patches or commit messages from either the
|
------------------------------------------------
|
||||||
<file> arguments or the standard input if no <file> is specified. If
|
subject
|
||||||
`--parse` is specified, the output consists of the parsed trailers.
|
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
|
|
||||||
|
Signed-off-by: Alice <alice@example.com>
|
||||||
|
Signed-off-by: Bob <bob@example.com>
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
the last two lines starting with "Signed-off-by" are trailers.
|
||||||
|
|
||||||
|
This command reads commit messages from either the
|
||||||
|
<file> arguments or the standard input if no <file> is specified.
|
||||||
|
If `--parse` is specified, the output consists of the parsed trailers.
|
||||||
Otherwise, this command applies the arguments passed using the
|
Otherwise, this command applies the arguments passed using the
|
||||||
`--trailer` option, if any, to the commit message part of each input
|
`--trailer` option, if any, to each input file. The result is emitted on the
|
||||||
file. The result is emitted on the standard output.
|
standard output.
|
||||||
|
|
||||||
|
This command can also operate on the output of linkgit:git-format-patch[1],
|
||||||
|
which is more elaborate than a plain commit message. Namely, such output
|
||||||
|
includes a commit message (as above), a "---" divider line, and a patch part.
|
||||||
|
For these inputs, the divider and patch parts are not modified by
|
||||||
|
this command and are emitted as is on the output, unless
|
||||||
|
`--no-divider` is specified.
|
||||||
|
|
||||||
Some configuration variables control the way the `--trailer` arguments
|
Some configuration variables control the way the `--trailer` arguments
|
||||||
are applied to each commit message and the way any existing trailer in
|
are applied to each input and the way any existing trailer in
|
||||||
the commit message is changed. They also make it possible to
|
the input is changed. They also make it possible to
|
||||||
automatically add some trailers.
|
automatically add some trailers.
|
||||||
|
|
||||||
By default, a '<token>=<value>' or '<token>:<value>' argument given
|
By default, a '<token>=<value>' or '<token>:<value>' argument given
|
||||||
@ -36,41 +53,46 @@ using `--trailer` will be appended after the existing trailers only if
|
|||||||
the last trailer has a different (<token>, <value>) pair (or if there
|
the last trailer has a different (<token>, <value>) pair (or if there
|
||||||
is no existing trailer). The <token> and <value> parts will be trimmed
|
is no existing trailer). The <token> and <value> parts will be trimmed
|
||||||
to remove starting and trailing whitespace, and the resulting trimmed
|
to remove starting and trailing whitespace, and the resulting trimmed
|
||||||
<token> and <value> will appear in the message like this:
|
<token> and <value> will appear in the output like this:
|
||||||
|
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
token: value
|
token: value
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
This means that the trimmed <token> and <value> will be separated by
|
This means that the trimmed <token> and <value> will be separated by
|
||||||
`': '` (one colon followed by one space).
|
`': '` (one colon followed by one space). For convenience, the <token> can be a
|
||||||
|
shortened string key (e.g., "sign") instead of the full string which should
|
||||||
|
appear before the separator on the output (e.g., "Signed-off-by"). This can be
|
||||||
|
configured using the 'trailer.<token>.key' configuration variable.
|
||||||
|
|
||||||
By default the new trailer will appear at the end of all the existing
|
By default the new trailer will appear at the end of all the existing
|
||||||
trailers. If there is no existing trailer, the new trailer will appear
|
trailers. If there is no existing trailer, the new trailer will appear
|
||||||
after the commit message part of the output, and, if there is no line
|
at the end of the input. A blank line will be added before the new
|
||||||
with only spaces at the end of the commit message part, one blank line
|
trailer if there isn't one already.
|
||||||
will be added before the new trailer.
|
|
||||||
|
|
||||||
Existing trailers are extracted from the input message by looking for
|
Existing trailers are extracted from the input by looking for
|
||||||
a group of one or more lines that (i) is all trailers, or (ii) contains at
|
a group of one or more lines that (i) is all trailers, or (ii) contains at
|
||||||
least one Git-generated or user-configured trailer and consists of at
|
least one Git-generated or user-configured trailer and consists of at
|
||||||
least 25% trailers.
|
least 25% trailers.
|
||||||
The group must be preceded by one or more empty (or whitespace-only) lines.
|
The group must be preceded by one or more empty (or whitespace-only) lines.
|
||||||
The group must either be at the end of the message or be the last
|
The group must either be at the end of the input or be the last
|
||||||
non-whitespace lines before a line that starts with '---' (followed by a
|
non-whitespace lines before a line that starts with '---' (followed by a
|
||||||
space or the end of the line). Such three minus signs start the patch
|
space or the end of the line).
|
||||||
part of the message. See also `--no-divider` below.
|
|
||||||
|
|
||||||
When reading trailers, there can be no whitespace before or inside the
|
When reading trailers, there can be no whitespace before or inside the
|
||||||
token, but any number of regular space and tab characters are allowed
|
<token>, but any number of regular space and tab characters are allowed
|
||||||
between the token and the separator. There can be whitespaces before,
|
between the <token> and the separator. There can be whitespaces before,
|
||||||
inside or after the value. The value may be split over multiple lines
|
inside or after the <value>. The <value> may be split over multiple lines
|
||||||
with each subsequent line starting with at least one whitespace, like
|
with each subsequent line starting with at least one whitespace, like
|
||||||
the "folding" in RFC 822.
|
the "folding" in RFC 822. Example:
|
||||||
|
|
||||||
Note that 'trailers' do not follow and are not intended to follow many
|
------------------------------------------------
|
||||||
rules for RFC 822 headers. For example they do not follow
|
token: This is a very long value, with spaces and
|
||||||
the encoding rules and probably many other rules.
|
newlines in it.
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
Note that trailers do not follow (nor are they intended to follow) many of the
|
||||||
|
rules for RFC 822 headers. For example they do not follow the encoding rule.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-------
|
-------
|
||||||
@ -79,12 +101,12 @@ OPTIONS
|
|||||||
|
|
||||||
--trim-empty::
|
--trim-empty::
|
||||||
If the <value> part of any trailer contains only whitespace,
|
If the <value> part of any trailer contains only whitespace,
|
||||||
the whole trailer will be removed from the resulting message.
|
the whole trailer will be removed from the output.
|
||||||
This applies to existing trailers as well as new trailers.
|
This applies to existing trailers as well as new trailers.
|
||||||
|
|
||||||
--trailer <token>[(=|:)<value>]::
|
--trailer <token>[(=|:)<value>]::
|
||||||
Specify a (<token>, <value>) pair that should be applied as a
|
Specify a (<token>, <value>) pair that should be applied as a
|
||||||
trailer to the input messages. See the description of this
|
trailer to the inputs. See the description of this
|
||||||
command.
|
command.
|
||||||
|
|
||||||
--where <placement>::
|
--where <placement>::
|
||||||
@ -98,7 +120,7 @@ OPTIONS
|
|||||||
--if-exists <action>::
|
--if-exists <action>::
|
||||||
--no-if-exists::
|
--no-if-exists::
|
||||||
Specify what action will be performed when there is already at
|
Specify what action will be performed when there is already at
|
||||||
least one trailer with the same <token> in the message. A setting
|
least one trailer with the same <token> in the input. A setting
|
||||||
provided with '--if-exists' overrides all configuration variables
|
provided with '--if-exists' overrides all configuration variables
|
||||||
and applies to all '--trailer' options until the next occurrence of
|
and applies to all '--trailer' options until the next occurrence of
|
||||||
'--if-exists' or '--no-if-exists'. Possible actions are `addIfDifferent`,
|
'--if-exists' or '--no-if-exists'. Possible actions are `addIfDifferent`,
|
||||||
@ -107,7 +129,7 @@ OPTIONS
|
|||||||
--if-missing <action>::
|
--if-missing <action>::
|
||||||
--no-if-missing::
|
--no-if-missing::
|
||||||
Specify what action will be performed when there is no other
|
Specify what action will be performed when there is no other
|
||||||
trailer with the same <token> in the message. A setting
|
trailer with the same <token> in the input. A setting
|
||||||
provided with '--if-missing' overrides all configuration variables
|
provided with '--if-missing' overrides all configuration variables
|
||||||
and applies to all '--trailer' options until the next occurrence of
|
and applies to all '--trailer' options until the next occurrence of
|
||||||
'--if-missing' or '--no-if-missing'. Possible actions are `doNothing`
|
'--if-missing' or '--no-if-missing'. Possible actions are `doNothing`
|
||||||
@ -174,7 +196,7 @@ first trailer with the same <token>.
|
|||||||
trailer.ifexists::
|
trailer.ifexists::
|
||||||
This option makes it possible to choose what action will be
|
This option makes it possible to choose what action will be
|
||||||
performed when there is already at least one trailer with the
|
performed when there is already at least one trailer with the
|
||||||
same <token> in the message.
|
same <token> in the input.
|
||||||
+
|
+
|
||||||
The valid values for this option are: `addIfDifferentNeighbor` (this
|
The valid values for this option are: `addIfDifferentNeighbor` (this
|
||||||
is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
|
is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
|
||||||
@ -184,10 +206,10 @@ trailer with the same (<token>, <value>) pair is above or below the line
|
|||||||
where the new trailer will be added.
|
where the new trailer will be added.
|
||||||
+
|
+
|
||||||
With `addIfDifferent`, a new trailer will be added only if no trailer
|
With `addIfDifferent`, a new trailer will be added only if no trailer
|
||||||
with the same (<token>, <value>) pair is already in the message.
|
with the same (<token>, <value>) pair is already in the input.
|
||||||
+
|
+
|
||||||
With `add`, a new trailer will be added, even if some trailers with
|
With `add`, a new trailer will be added, even if some trailers with
|
||||||
the same (<token>, <value>) pair are already in the message.
|
the same (<token>, <value>) pair are already in the input.
|
||||||
+
|
+
|
||||||
With `replace`, an existing trailer with the same <token> will be
|
With `replace`, an existing trailer with the same <token> will be
|
||||||
deleted and the new trailer will be added. The deleted trailer will be
|
deleted and the new trailer will be added. The deleted trailer will be
|
||||||
@ -195,12 +217,12 @@ the closest one (with the same <token>) to the place where the new one
|
|||||||
will be added.
|
will be added.
|
||||||
+
|
+
|
||||||
With `doNothing`, nothing will be done; that is no new trailer will be
|
With `doNothing`, nothing will be done; that is no new trailer will be
|
||||||
added if there is already one with the same <token> in the message.
|
added if there is already one with the same <token> in the input.
|
||||||
|
|
||||||
trailer.ifmissing::
|
trailer.ifmissing::
|
||||||
This option makes it possible to choose what action will be
|
This option makes it possible to choose what action will be
|
||||||
performed when there is not yet any trailer with the same
|
performed when there is not yet any trailer with the same
|
||||||
<token> in the message.
|
<token> in the input.
|
||||||
+
|
+
|
||||||
The valid values for this option are: `add` (this is the default) and
|
The valid values for this option are: `add` (this is the default) and
|
||||||
`doNothing`.
|
`doNothing`.
|
||||||
@ -235,13 +257,13 @@ trailer.<token>.ifmissing::
|
|||||||
that option for trailers with the specified <token>.
|
that option for trailers with the specified <token>.
|
||||||
|
|
||||||
trailer.<token>.command::
|
trailer.<token>.command::
|
||||||
|
Deprecated in favor of 'trailer.<token>.cmd'.
|
||||||
This option behaves in the same way as 'trailer.<token>.cmd', except
|
This option behaves in the same way as 'trailer.<token>.cmd', except
|
||||||
that it doesn't pass anything as argument to the specified command.
|
that it doesn't pass anything as argument to the specified command.
|
||||||
Instead the first occurrence of substring $ARG is replaced by the
|
Instead the first occurrence of substring $ARG is replaced by the
|
||||||
value that would be passed as argument.
|
<value> that would be passed as argument.
|
||||||
+
|
+
|
||||||
The 'trailer.<token>.command' option has been deprecated in favor of
|
Note that $ARG in the user's command is
|
||||||
'trailer.<token>.cmd' due to the fact that $ARG in the user's command is
|
|
||||||
only replaced once and that the original way of replacing $ARG is not safe.
|
only replaced once and that the original way of replacing $ARG is not safe.
|
||||||
+
|
+
|
||||||
When both 'trailer.<token>.cmd' and 'trailer.<token>.command' are given
|
When both 'trailer.<token>.cmd' and 'trailer.<token>.command' are given
|
||||||
@ -249,10 +271,10 @@ for the same <token>, 'trailer.<token>.cmd' is used and
|
|||||||
'trailer.<token>.command' is ignored.
|
'trailer.<token>.command' is ignored.
|
||||||
|
|
||||||
trailer.<token>.cmd::
|
trailer.<token>.cmd::
|
||||||
This option can be used to specify a shell command that will be called:
|
This option can be used to specify a shell command that will be called
|
||||||
once to automatically add a trailer with the specified <token>, and then
|
once to automatically add a trailer with the specified <token>, and then
|
||||||
each time a '--trailer <token>=<value>' argument to modify the <value> of
|
called each time a '--trailer <token>=<value>' argument is specified to
|
||||||
the trailer that this option would produce.
|
modify the <value> of the trailer that this option would produce.
|
||||||
+
|
+
|
||||||
When the specified command is first called to add a trailer
|
When the specified command is first called to add a trailer
|
||||||
with the specified <token>, the behavior is as if a special
|
with the specified <token>, the behavior is as if a special
|
||||||
@ -272,37 +294,37 @@ EXAMPLES
|
|||||||
--------
|
--------
|
||||||
|
|
||||||
* Configure a 'sign' trailer with a 'Signed-off-by' key, and then
|
* Configure a 'sign' trailer with a 'Signed-off-by' key, and then
|
||||||
add two of these trailers to a message:
|
add two of these trailers to a commit message file:
|
||||||
+
|
+
|
||||||
------------
|
------------
|
||||||
$ git config trailer.sign.key "Signed-off-by"
|
$ git config trailer.sign.key "Signed-off-by"
|
||||||
$ cat msg.txt
|
$ cat msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
$ git interpret-trailers --trailer 'sign: Alice <alice@example.com>' --trailer 'sign: Bob <bob@example.com>' <msg.txt
|
$ git interpret-trailers --trailer 'sign: Alice <alice@example.com>' --trailer 'sign: Bob <bob@example.com>' <msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
Signed-off-by: Alice <alice@example.com>
|
Signed-off-by: Alice <alice@example.com>
|
||||||
Signed-off-by: Bob <bob@example.com>
|
Signed-off-by: Bob <bob@example.com>
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Use the `--in-place` option to edit a message file in place:
|
* Use the `--in-place` option to edit a commit message file in place:
|
||||||
+
|
+
|
||||||
------------
|
------------
|
||||||
$ cat msg.txt
|
$ cat msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
Signed-off-by: Bob <bob@example.com>
|
Signed-off-by: Bob <bob@example.com>
|
||||||
$ git interpret-trailers --trailer 'Acked-by: Alice <alice@example.com>' --in-place msg.txt
|
$ git interpret-trailers --trailer 'Acked-by: Alice <alice@example.com>' --in-place msg.txt
|
||||||
$ cat msg.txt
|
$ cat msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
Signed-off-by: Bob <bob@example.com>
|
Signed-off-by: Bob <bob@example.com>
|
||||||
Acked-by: Alice <alice@example.com>
|
Acked-by: Alice <alice@example.com>
|
||||||
@ -325,7 +347,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <alice@example.com>' --trailer 'Re
|
|||||||
$ cat msg1.txt
|
$ cat msg1.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
$ git config trailer.sign.key "Signed-off-by: "
|
$ git config trailer.sign.key "Signed-off-by: "
|
||||||
$ git config trailer.sign.ifmissing add
|
$ git config trailer.sign.ifmissing add
|
||||||
$ git config trailer.sign.ifexists doNothing
|
$ git config trailer.sign.ifexists doNothing
|
||||||
@ -333,19 +355,19 @@ $ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.
|
|||||||
$ git interpret-trailers --trailer sign <msg1.txt
|
$ git interpret-trailers --trailer sign <msg1.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
Signed-off-by: Bob <bob@example.com>
|
Signed-off-by: Bob <bob@example.com>
|
||||||
$ cat msg2.txt
|
$ cat msg2.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
Signed-off-by: Alice <alice@example.com>
|
Signed-off-by: Alice <alice@example.com>
|
||||||
$ git interpret-trailers --trailer sign <msg2.txt
|
$ git interpret-trailers --trailer sign <msg2.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
Signed-off-by: Alice <alice@example.com>
|
Signed-off-by: Alice <alice@example.com>
|
||||||
------------
|
------------
|
||||||
@ -373,14 +395,14 @@ test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true
|
|||||||
$ cat msg.txt
|
$ cat msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
$ git config trailer.help.key "Helped-by: "
|
$ git config trailer.help.key "Helped-by: "
|
||||||
$ git config trailer.help.ifExists "addIfDifferentNeighbor"
|
$ git config trailer.help.ifExists "addIfDifferentNeighbor"
|
||||||
$ git config trailer.help.cmd "~/bin/glog-find-author"
|
$ git config trailer.help.cmd "~/bin/glog-find-author"
|
||||||
$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt
|
$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
Helped-by: Junio C Hamano <gitster@pobox.com>
|
Helped-by: Junio C Hamano <gitster@pobox.com>
|
||||||
Helped-by: Christian Couder <christian.couder@gmail.com>
|
Helped-by: Christian Couder <christian.couder@gmail.com>
|
||||||
@ -397,14 +419,14 @@ test -n "$1" && git log --grep "$1" --pretty=reference -1 || true
|
|||||||
$ cat msg.txt
|
$ cat msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
$ git config trailer.ref.key "Reference-to: "
|
$ git config trailer.ref.key "Reference-to: "
|
||||||
$ git config trailer.ref.ifExists "replace"
|
$ git config trailer.ref.ifExists "replace"
|
||||||
$ git config trailer.ref.cmd "~/bin/glog-grep"
|
$ git config trailer.ref.cmd "~/bin/glog-grep"
|
||||||
$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt
|
$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
|
Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
|
||||||
------------
|
------------
|
||||||
@ -416,7 +438,7 @@ Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
|
|||||||
$ cat msg.txt
|
$ cat msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
see: HEAD~2
|
see: HEAD~2
|
||||||
$ cat ~/bin/glog-ref
|
$ cat ~/bin/glog-ref
|
||||||
@ -429,7 +451,7 @@ $ git config trailer.see.cmd "glog-ref"
|
|||||||
$ git interpret-trailers --trailer=see <msg.txt
|
$ git interpret-trailers --trailer=see <msg.txt
|
||||||
subject
|
subject
|
||||||
|
|
||||||
message
|
body text
|
||||||
|
|
||||||
See-also: fe3187489d69c4 (subject of related commit)
|
See-also: fe3187489d69c4 (subject of related commit)
|
||||||
------------
|
------------
|
||||||
|
Reference in New Issue
Block a user