Skip to content

Commit 917d4c2

Browse files
committed
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
2 parents de00f4b + d57fa7f commit 917d4c2

File tree

1 file changed

+78
-56
lines changed

1 file changed

+78
-56
lines changed

Documentation/git-interpret-trailers.txt

Lines changed: 78 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,85 @@ SYNOPSIS
1414

1515
DESCRIPTION
1616
-----------
17-
Help parsing or adding 'trailers' lines, that look similar to RFC 822 e-mail
17+
Add or parse 'trailer' lines that look similar to RFC 822 e-mail
1818
headers, at the end of the otherwise free-form part of a commit
19-
message.
19+
message. For example, in the following commit message
2020

21-
This command reads some patches or commit messages from either the
22-
<file> arguments or the standard input if no <file> is specified. If
23-
`--parse` is specified, the output consists of the parsed trailers.
21+
------------------------------------------------
22+
subject
23+
24+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
25+
26+
Signed-off-by: Alice <[email protected]>
27+
Signed-off-by: Bob <[email protected]>
28+
------------------------------------------------
29+
30+
the last two lines starting with "Signed-off-by" are trailers.
2431

32+
This command reads commit messages from either the
33+
<file> arguments or the standard input if no <file> is specified.
34+
If `--parse` is specified, the output consists of the parsed trailers.
2535
Otherwise, this command applies the arguments passed using the
26-
`--trailer` option, if any, to the commit message part of each input
27-
file. The result is emitted on the standard output.
36+
`--trailer` option, if any, to each input file. The result is emitted on the
37+
standard output.
38+
39+
This command can also operate on the output of linkgit:git-format-patch[1],
40+
which is more elaborate than a plain commit message. Namely, such output
41+
includes a commit message (as above), a "---" divider line, and a patch part.
42+
For these inputs, the divider and patch parts are not modified by
43+
this command and are emitted as is on the output, unless
44+
`--no-divider` is specified.
2845

2946
Some configuration variables control the way the `--trailer` arguments
30-
are applied to each commit message and the way any existing trailer in
31-
the commit message is changed. They also make it possible to
47+
are applied to each input and the way any existing trailer in
48+
the input is changed. They also make it possible to
3249
automatically add some trailers.
3350

3451
By default, a '<token>=<value>' or '<token>:<value>' argument given
3552
using `--trailer` will be appended after the existing trailers only if
3653
the last trailer has a different (<token>, <value>) pair (or if there
3754
is no existing trailer). The <token> and <value> parts will be trimmed
3855
to remove starting and trailing whitespace, and the resulting trimmed
39-
<token> and <value> will appear in the message like this:
56+
<token> and <value> will appear in the output like this:
4057

4158
------------------------------------------------
4259
token: value
4360
------------------------------------------------
4461

4562
This means that the trimmed <token> and <value> will be separated by
46-
`': '` (one colon followed by one space).
63+
`': '` (one colon followed by one space). For convenience, the <token> can be a
64+
shortened string key (e.g., "sign") instead of the full string which should
65+
appear before the separator on the output (e.g., "Signed-off-by"). This can be
66+
configured using the 'trailer.<token>.key' configuration variable.
4767

4868
By default the new trailer will appear at the end of all the existing
4969
trailers. If there is no existing trailer, the new trailer will appear
50-
after the commit message part of the output, and, if there is no line
51-
with only spaces at the end of the commit message part, one blank line
52-
will be added before the new trailer.
70+
at the end of the input. A blank line will be added before the new
71+
trailer if there isn't one already.
5372

54-
Existing trailers are extracted from the input message by looking for
73+
Existing trailers are extracted from the input by looking for
5574
a group of one or more lines that (i) is all trailers, or (ii) contains at
5675
least one Git-generated or user-configured trailer and consists of at
5776
least 25% trailers.
5877
The group must be preceded by one or more empty (or whitespace-only) lines.
59-
The group must either be at the end of the message or be the last
78+
The group must either be at the end of the input or be the last
6079
non-whitespace lines before a line that starts with '---' (followed by a
61-
space or the end of the line). Such three minus signs start the patch
62-
part of the message. See also `--no-divider` below.
80+
space or the end of the line).
6381

6482
When reading trailers, there can be no whitespace before or inside the
65-
token, but any number of regular space and tab characters are allowed
66-
between the token and the separator. There can be whitespaces before,
67-
inside or after the value. The value may be split over multiple lines
83+
<token>, but any number of regular space and tab characters are allowed
84+
between the <token> and the separator. There can be whitespaces before,
85+
inside or after the <value>. The <value> may be split over multiple lines
6886
with each subsequent line starting with at least one whitespace, like
69-
the "folding" in RFC 822.
87+
the "folding" in RFC 822. Example:
88+
89+
------------------------------------------------
90+
token: This is a very long value, with spaces and
91+
newlines in it.
92+
------------------------------------------------
7093

71-
Note that 'trailers' do not follow and are not intended to follow many
72-
rules for RFC 822 headers. For example they do not follow
73-
the encoding rules and probably many other rules.
94+
Note that trailers do not follow (nor are they intended to follow) many of the
95+
rules for RFC 822 headers. For example they do not follow the encoding rule.
7496

7597
OPTIONS
7698
-------
@@ -79,12 +101,12 @@ OPTIONS
79101

80102
--trim-empty::
81103
If the <value> part of any trailer contains only whitespace,
82-
the whole trailer will be removed from the resulting message.
104+
the whole trailer will be removed from the output.
83105
This applies to existing trailers as well as new trailers.
84106

85107
--trailer <token>[(=|:)<value>]::
86108
Specify a (<token>, <value>) pair that should be applied as a
87-
trailer to the input messages. See the description of this
109+
trailer to the inputs. See the description of this
88110
command.
89111

90112
--where <placement>::
@@ -98,7 +120,7 @@ OPTIONS
98120
--if-exists <action>::
99121
--no-if-exists::
100122
Specify what action will be performed when there is already at
101-
least one trailer with the same <token> in the message. A setting
123+
least one trailer with the same <token> in the input. A setting
102124
provided with '--if-exists' overrides all configuration variables
103125
and applies to all '--trailer' options until the next occurrence of
104126
'--if-exists' or '--no-if-exists'. Possible actions are `addIfDifferent`,
@@ -107,7 +129,7 @@ OPTIONS
107129
--if-missing <action>::
108130
--no-if-missing::
109131
Specify what action will be performed when there is no other
110-
trailer with the same <token> in the message. A setting
132+
trailer with the same <token> in the input. A setting
111133
provided with '--if-missing' overrides all configuration variables
112134
and applies to all '--trailer' options until the next occurrence of
113135
'--if-missing' or '--no-if-missing'. Possible actions are `doNothing`
@@ -174,7 +196,7 @@ first trailer with the same <token>.
174196
trailer.ifexists::
175197
This option makes it possible to choose what action will be
176198
performed when there is already at least one trailer with the
177-
same <token> in the message.
199+
same <token> in the input.
178200
+
179201
The valid values for this option are: `addIfDifferentNeighbor` (this
180202
is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
@@ -184,23 +206,23 @@ trailer with the same (<token>, <value>) pair is above or below the line
184206
where the new trailer will be added.
185207
+
186208
With `addIfDifferent`, a new trailer will be added only if no trailer
187-
with the same (<token>, <value>) pair is already in the message.
209+
with the same (<token>, <value>) pair is already in the input.
188210
+
189211
With `add`, a new trailer will be added, even if some trailers with
190-
the same (<token>, <value>) pair are already in the message.
212+
the same (<token>, <value>) pair are already in the input.
191213
+
192214
With `replace`, an existing trailer with the same <token> will be
193215
deleted and the new trailer will be added. The deleted trailer will be
194216
the closest one (with the same <token>) to the place where the new one
195217
will be added.
196218
+
197219
With `doNothing`, nothing will be done; that is no new trailer will be
198-
added if there is already one with the same <token> in the message.
220+
added if there is already one with the same <token> in the input.
199221

200222
trailer.ifmissing::
201223
This option makes it possible to choose what action will be
202224
performed when there is not yet any trailer with the same
203-
<token> in the message.
225+
<token> in the input.
204226
+
205227
The valid values for this option are: `add` (this is the default) and
206228
`doNothing`.
@@ -235,24 +257,24 @@ trailer.<token>.ifmissing::
235257
that option for trailers with the specified <token>.
236258

237259
trailer.<token>.command::
260+
Deprecated in favor of 'trailer.<token>.cmd'.
238261
This option behaves in the same way as 'trailer.<token>.cmd', except
239262
that it doesn't pass anything as argument to the specified command.
240263
Instead the first occurrence of substring $ARG is replaced by the
241-
value that would be passed as argument.
264+
<value> that would be passed as argument.
242265
+
243-
The 'trailer.<token>.command' option has been deprecated in favor of
244-
'trailer.<token>.cmd' due to the fact that $ARG in the user's command is
266+
Note that $ARG in the user's command is
245267
only replaced once and that the original way of replacing $ARG is not safe.
246268
+
247269
When both 'trailer.<token>.cmd' and 'trailer.<token>.command' are given
248270
for the same <token>, 'trailer.<token>.cmd' is used and
249271
'trailer.<token>.command' is ignored.
250272

251273
trailer.<token>.cmd::
252-
This option can be used to specify a shell command that will be called:
274+
This option can be used to specify a shell command that will be called
253275
once to automatically add a trailer with the specified <token>, and then
254-
each time a '--trailer <token>=<value>' argument to modify the <value> of
255-
the trailer that this option would produce.
276+
called each time a '--trailer <token>=<value>' argument is specified to
277+
modify the <value> of the trailer that this option would produce.
256278
+
257279
When the specified command is first called to add a trailer
258280
with the specified <token>, the behavior is as if a special
@@ -272,37 +294,37 @@ EXAMPLES
272294
--------
273295

274296
* Configure a 'sign' trailer with a 'Signed-off-by' key, and then
275-
add two of these trailers to a message:
297+
add two of these trailers to a commit message file:
276298
+
277299
------------
278300
$ git config trailer.sign.key "Signed-off-by"
279301
$ cat msg.txt
280302
subject
281303

282-
message
304+
body text
283305
$ git interpret-trailers --trailer 'sign: Alice <[email protected]>' --trailer 'sign: Bob <[email protected]>' <msg.txt
284306
subject
285307

286-
message
308+
body text
287309

288310
Signed-off-by: Alice <[email protected]>
289311
Signed-off-by: Bob <[email protected]>
290312
------------
291313

292-
* Use the `--in-place` option to edit a message file in place:
314+
* Use the `--in-place` option to edit a commit message file in place:
293315
+
294316
------------
295317
$ cat msg.txt
296318
subject
297319

298-
message
320+
body text
299321

300322
Signed-off-by: Bob <[email protected]>
301323
$ git interpret-trailers --trailer 'Acked-by: Alice <[email protected]>' --in-place msg.txt
302324
$ cat msg.txt
303325
subject
304326

305-
message
327+
body text
306328

307329
Signed-off-by: Bob <[email protected]>
308330
Acked-by: Alice <[email protected]>
@@ -325,27 +347,27 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re
325347
$ cat msg1.txt
326348
subject
327349

328-
message
350+
body text
329351
$ git config trailer.sign.key "Signed-off-by: "
330352
$ git config trailer.sign.ifmissing add
331353
$ git config trailer.sign.ifexists doNothing
332354
$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"'
333355
$ git interpret-trailers --trailer sign <msg1.txt
334356
subject
335357

336-
message
358+
body text
337359

338360
Signed-off-by: Bob <[email protected]>
339361
$ cat msg2.txt
340362
subject
341363

342-
message
364+
body text
343365

344366
Signed-off-by: Alice <[email protected]>
345367
$ git interpret-trailers --trailer sign <msg2.txt
346368
subject
347369

348-
message
370+
body text
349371

350372
Signed-off-by: Alice <[email protected]>
351373
------------
@@ -373,14 +395,14 @@ test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true
373395
$ cat msg.txt
374396
subject
375397

376-
message
398+
body text
377399
$ git config trailer.help.key "Helped-by: "
378400
$ git config trailer.help.ifExists "addIfDifferentNeighbor"
379401
$ git config trailer.help.cmd "~/bin/glog-find-author"
380402
$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt
381403
subject
382404

383-
message
405+
body text
384406

385407
Helped-by: Junio C Hamano <[email protected]>
386408
Helped-by: Christian Couder <[email protected]>
@@ -397,14 +419,14 @@ test -n "$1" && git log --grep "$1" --pretty=reference -1 || true
397419
$ cat msg.txt
398420
subject
399421

400-
message
422+
body text
401423
$ git config trailer.ref.key "Reference-to: "
402424
$ git config trailer.ref.ifExists "replace"
403425
$ git config trailer.ref.cmd "~/bin/glog-grep"
404426
$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt
405427
subject
406428

407-
message
429+
body text
408430

409431
Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
410432
------------
@@ -416,7 +438,7 @@ Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
416438
$ cat msg.txt
417439
subject
418440

419-
message
441+
body text
420442

421443
see: HEAD~2
422444
$ cat ~/bin/glog-ref
@@ -429,7 +451,7 @@ $ git config trailer.see.cmd "glog-ref"
429451
$ git interpret-trailers --trailer=see <msg.txt
430452
subject
431453

432-
message
454+
body text
433455

434456
See-also: fe3187489d69c4 (subject of related commit)
435457
------------

0 commit comments

Comments
 (0)