@@ -14,63 +14,85 @@ SYNOPSIS
14
14
15
15
DESCRIPTION
16
16
-----------
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
18
18
headers, at the end of the otherwise free-form part of a commit
19
- message.
19
+ message. For example, in the following commit message
20
20
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.
24
31
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.
25
35
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.
28
45
29
46
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
32
49
automatically add some trailers.
33
50
34
51
By default, a '<token>=<value>' or '<token>:<value>' argument given
35
52
using `--trailer` will be appended after the existing trailers only if
36
53
the last trailer has a different (<token>, <value>) pair (or if there
37
54
is no existing trailer). The <token> and <value> parts will be trimmed
38
55
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:
40
57
41
58
------------------------------------------------
42
59
token: value
43
60
------------------------------------------------
44
61
45
62
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.
47
67
48
68
By default the new trailer will appear at the end of all the existing
49
69
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.
53
72
54
- Existing trailers are extracted from the input message by looking for
73
+ Existing trailers are extracted from the input by looking for
55
74
a group of one or more lines that (i) is all trailers, or (ii) contains at
56
75
least one Git-generated or user-configured trailer and consists of at
57
76
least 25% trailers.
58
77
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
60
79
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).
63
81
64
82
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
68
86
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
+ ------------------------------------------------
70
93
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.
74
96
75
97
OPTIONS
76
98
-------
@@ -79,12 +101,12 @@ OPTIONS
79
101
80
102
--trim-empty::
81
103
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 .
83
105
This applies to existing trailers as well as new trailers.
84
106
85
107
--trailer <token>[(=|:)<value>]::
86
108
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
88
110
command.
89
111
90
112
--where <placement>::
@@ -98,7 +120,7 @@ OPTIONS
98
120
--if-exists <action>::
99
121
--no-if-exists::
100
122
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
102
124
provided with '--if-exists' overrides all configuration variables
103
125
and applies to all '--trailer' options until the next occurrence of
104
126
'--if-exists' or '--no-if-exists'. Possible actions are `addIfDifferent`,
@@ -107,7 +129,7 @@ OPTIONS
107
129
--if-missing <action>::
108
130
--no-if-missing::
109
131
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
111
133
provided with '--if-missing' overrides all configuration variables
112
134
and applies to all '--trailer' options until the next occurrence of
113
135
'--if-missing' or '--no-if-missing'. Possible actions are `doNothing`
@@ -174,7 +196,7 @@ first trailer with the same <token>.
174
196
trailer.ifexists::
175
197
This option makes it possible to choose what action will be
176
198
performed when there is already at least one trailer with the
177
- same <token> in the message .
199
+ same <token> in the input .
178
200
+
179
201
The valid values for this option are: `addIfDifferentNeighbor` (this
180
202
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
184
206
where the new trailer will be added.
185
207
+
186
208
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 .
188
210
+
189
211
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 .
191
213
+
192
214
With `replace`, an existing trailer with the same <token> will be
193
215
deleted and the new trailer will be added. The deleted trailer will be
194
216
the closest one (with the same <token>) to the place where the new one
195
217
will be added.
196
218
+
197
219
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 .
199
221
200
222
trailer.ifmissing::
201
223
This option makes it possible to choose what action will be
202
224
performed when there is not yet any trailer with the same
203
- <token> in the message .
225
+ <token> in the input .
204
226
+
205
227
The valid values for this option are: `add` (this is the default) and
206
228
`doNothing`.
@@ -235,24 +257,24 @@ trailer.<token>.ifmissing::
235
257
that option for trailers with the specified <token>.
236
258
237
259
trailer.<token>.command::
260
+ Deprecated in favor of 'trailer.<token>.cmd'.
238
261
This option behaves in the same way as 'trailer.<token>.cmd', except
239
262
that it doesn't pass anything as argument to the specified command.
240
263
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.
242
265
+
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
245
267
only replaced once and that the original way of replacing $ARG is not safe.
246
268
+
247
269
When both 'trailer.<token>.cmd' and 'trailer.<token>.command' are given
248
270
for the same <token>, 'trailer.<token>.cmd' is used and
249
271
'trailer.<token>.command' is ignored.
250
272
251
273
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
253
275
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.
256
278
+
257
279
When the specified command is first called to add a trailer
258
280
with the specified <token>, the behavior is as if a special
@@ -272,37 +294,37 @@ EXAMPLES
272
294
--------
273
295
274
296
* 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 :
276
298
+
277
299
------------
278
300
$ git config trailer.sign.key "Signed-off-by"
279
301
$ cat msg.txt
280
302
subject
281
303
282
- message
304
+ body text
283
305
$ git interpret-trailers --trailer 'sign: Alice <
[email protected] >' --trailer 'sign: Bob <
[email protected] >' <msg.txt
284
306
subject
285
307
286
- message
308
+ body text
287
309
288
310
Signed-off-by: Alice <
[email protected] >
289
311
Signed-off-by: Bob <
[email protected] >
290
312
------------
291
313
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:
293
315
+
294
316
------------
295
317
$ cat msg.txt
296
318
subject
297
319
298
- message
320
+ body text
299
321
300
322
Signed-off-by: Bob <
[email protected] >
301
323
$ git interpret-trailers --trailer 'Acked-by: Alice <
[email protected] >' --in-place msg.txt
302
324
$ cat msg.txt
303
325
subject
304
326
305
- message
327
+ body text
306
328
307
329
Signed-off-by: Bob <
[email protected] >
308
330
Acked-by: Alice <
[email protected] >
@@ -325,27 +347,27 @@ $ git interpret-trailers --trailer 'Cc: Alice <
[email protected] >' --trailer 'Re
325
347
$ cat msg1.txt
326
348
subject
327
349
328
- message
350
+ body text
329
351
$ git config trailer.sign.key "Signed-off-by: "
330
352
$ git config trailer.sign.ifmissing add
331
353
$ git config trailer.sign.ifexists doNothing
332
354
$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"'
333
355
$ git interpret-trailers --trailer sign <msg1.txt
334
356
subject
335
357
336
- message
358
+ body text
337
359
338
360
Signed-off-by: Bob <
[email protected] >
339
361
$ cat msg2.txt
340
362
subject
341
363
342
- message
364
+ body text
343
365
344
366
Signed-off-by: Alice <
[email protected] >
345
367
$ git interpret-trailers --trailer sign <msg2.txt
346
368
subject
347
369
348
- message
370
+ body text
349
371
350
372
Signed-off-by: Alice <
[email protected] >
351
373
------------
@@ -373,14 +395,14 @@ test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true
373
395
$ cat msg.txt
374
396
subject
375
397
376
- message
398
+ body text
377
399
$ git config trailer.help.key "Helped-by: "
378
400
$ git config trailer.help.ifExists "addIfDifferentNeighbor"
379
401
$ git config trailer.help.cmd "~/bin/glog-find-author"
380
402
$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt
381
403
subject
382
404
383
- message
405
+ body text
384
406
385
407
Helped-by: Junio C Hamano <
[email protected] >
386
408
Helped-by: Christian Couder <
[email protected] >
@@ -397,14 +419,14 @@ test -n "$1" && git log --grep "$1" --pretty=reference -1 || true
397
419
$ cat msg.txt
398
420
subject
399
421
400
- message
422
+ body text
401
423
$ git config trailer.ref.key "Reference-to: "
402
424
$ git config trailer.ref.ifExists "replace"
403
425
$ git config trailer.ref.cmd "~/bin/glog-grep"
404
426
$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt
405
427
subject
406
428
407
- message
429
+ body text
408
430
409
431
Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
410
432
------------
@@ -416,7 +438,7 @@ Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)
416
438
$ cat msg.txt
417
439
subject
418
440
419
- message
441
+ body text
420
442
421
443
see: HEAD~2
422
444
$ cat ~/bin/glog-ref
@@ -429,7 +451,7 @@ $ git config trailer.see.cmd "glog-ref"
429
451
$ git interpret-trailers --trailer=see <msg.txt
430
452
subject
431
453
432
- message
454
+ body text
433
455
434
456
See-also: fe3187489d69c4 (subject of related commit)
435
457
------------
0 commit comments