9
9
--------
10
10
[verse]
11
11
'git interpret-trailers' [--in-place] [--trim-empty]
12
- [(--trailer <token> [(=|:)<value>])...]
12
+ [(--trailer (<key>|<keyAlias>) [(=|:)<value>])...]
13
13
[--parse] [<file>...]
14
14
15
15
DESCRIPTION
@@ -31,10 +31,15 @@ the last two lines starting with "Signed-off-by" are trailers.
31
31
32
32
This command reads commit messages from either the
33
33
<file> arguments or the standard input if no <file> is specified.
34
- If `--parse` is specified, the output consists of the parsed trailers.
35
- Otherwise, this command applies the arguments passed using the
36
- `--trailer` option, if any, to each input file. The result is emitted on the
37
- standard output.
34
+ If `--parse` is specified, the output consists of the parsed trailers
35
+ coming from the input, without influencing them with any command line
36
+ options or configuration variables.
37
+
38
+ Otherwise, this command applies `trailer.*` configuration variables
39
+ (which could potentially add new trailers, as well as reposition them),
40
+ as well as any command line arguments that can override configuration
41
+ variables (such as `--trailer=...` which could also add new trailers),
42
+ to each input file. The result is emitted on the standard output.
38
43
39
44
This command can also operate on the output of linkgit:git-format-patch[1],
40
45
which is more elaborate than a plain commit message. Namely, such output
@@ -48,22 +53,32 @@ are applied to each input and the way any existing trailer in
48
53
the input is changed. They also make it possible to
49
54
automatically add some trailers.
50
55
51
- By default, a '<token >=<value>' or '<token >:<value>' argument given
56
+ By default, a '<key >=<value>' or '<key >:<value>' argument given
52
57
using `--trailer` will be appended after the existing trailers only if
53
- the last trailer has a different (<token >, <value>) pair (or if there
54
- is no existing trailer). The <token > and <value> parts will be trimmed
58
+ the last trailer has a different (<key >, <value>) pair (or if there
59
+ is no existing trailer). The <key > and <value> parts will be trimmed
55
60
to remove starting and trailing whitespace, and the resulting trimmed
56
- <token > and <value> will appear in the output like this:
61
+ <key > and <value> will appear in the output like this:
57
62
58
63
------------------------------------------------
59
- token : value
64
+ key : value
60
65
------------------------------------------------
61
66
62
- This means that the trimmed <token> and <value> will be separated by
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.
67
+ This means that the trimmed <key> and <value> will be separated by
68
+ `': '` (one colon followed by one space).
69
+
70
+ For convenience, a <keyAlias> can be configured to make using `--trailer`
71
+ shorter to type on the command line. This can be configured using the
72
+ 'trailer.<keyAlias>.key' configuration variable. The <keyAlias> must be a prefix
73
+ of the full <key> string, although case sensitivity does not matter. For
74
+ example, if you have
75
+
76
+ ------------------------------------------------
77
+ trailer.sign.key "Signed-off-by: "
78
+ ------------------------------------------------
79
+
80
+ in your configuration, you only need to specify `--trailer="sign: foo"`
81
+ on the command line instead of `--trailer="Signed-off-by: foo"`.
67
82
68
83
By default the new trailer will appear at the end of all the existing
69
84
trailers. If there is no existing trailer, the new trailer will appear
@@ -80,14 +95,14 @@ non-whitespace lines before a line that starts with '---' (followed by a
80
95
space or the end of the line).
81
96
82
97
When reading trailers, there can be no whitespace before or inside the
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,
98
+ <key >, but any number of regular space and tab characters are allowed
99
+ between the <key > and the separator. There can be whitespaces before,
85
100
inside or after the <value>. The <value> may be split over multiple lines
86
101
with each subsequent line starting with at least one whitespace, like
87
102
the "folding" in RFC 822. Example:
88
103
89
104
------------------------------------------------
90
- token : This is a very long value, with spaces and
105
+ key : This is a very long value, with spaces and
91
106
newlines in it.
92
107
------------------------------------------------
93
108
@@ -104,52 +119,64 @@ OPTIONS
104
119
the whole trailer will be removed from the output.
105
120
This applies to existing trailers as well as new trailers.
106
121
107
- --trailer <token >[(=|:)<value>]::
108
- Specify a (<token >, <value>) pair that should be applied as a
122
+ --trailer <key >[(=|:)<value>]::
123
+ Specify a (<key >, <value>) pair that should be applied as a
109
124
trailer to the inputs. See the description of this
110
125
command.
111
126
112
127
--where <placement>::
113
128
--no-where::
114
129
Specify where all new trailers will be added. A setting
115
- provided with '--where' overrides all configuration variables
130
+ provided with '--where' overrides the `trailer.where` and any
131
+ applicable `trailer.<keyAlias>.where` configuration variables
116
132
and applies to all '--trailer' options until the next occurrence of
117
- '--where' or '--no-where'. Possible values are `after`, `before`,
118
- `end` or `start`.
133
+ '--where' or '--no-where'. Upon encountering '--no-where', clear the
134
+ effect of any previous use of '--where', such that the relevant configuration
135
+ variables are no longer overridden. Possible placements are `after`,
136
+ `before`, `end` or `start`.
119
137
120
138
--if-exists <action>::
121
139
--no-if-exists::
122
140
Specify what action will be performed when there is already at
123
- least one trailer with the same <token> in the input. A setting
124
- provided with '--if-exists' overrides all configuration variables
141
+ least one trailer with the same <key> in the input. A setting
142
+ provided with '--if-exists' overrides the `trailer.ifExists` and any
143
+ applicable `trailer.<keyAlias>.ifExists` configuration variables
125
144
and applies to all '--trailer' options until the next occurrence of
126
- '--if-exists' or '--no-if-exists'. Possible actions are `addIfDifferent`,
145
+ '--if-exists' or '--no-if-exists'. Upon encountering '--no-if-exists, clear the
146
+ effect of any previous use of '--if-exists, such that the relevant configuration
147
+ variables are no longer overridden. Possible actions are `addIfDifferent`,
127
148
`addIfDifferentNeighbor`, `add`, `replace` and `doNothing`.
128
149
129
150
--if-missing <action>::
130
151
--no-if-missing::
131
152
Specify what action will be performed when there is no other
132
- trailer with the same <token> in the input. A setting
133
- provided with '--if-missing' overrides all configuration variables
153
+ trailer with the same <key> in the input. A setting
154
+ provided with '--if-missing' overrides the `trailer.ifMissing` and any
155
+ applicable `trailer.<keyAlias>.ifMissing` configuration variables
134
156
and applies to all '--trailer' options until the next occurrence of
135
- '--if-missing' or '--no-if-missing'. Possible actions are `doNothing`
157
+ '--if-missing' or '--no-if-missing'. Upon encountering '--no-if-missing,
158
+ clear the effect of any previous use of '--if-missing, such that the relevant
159
+ configuration variables are no longer overridden. Possible actions are `doNothing`
136
160
or `add`.
137
161
138
162
--only-trailers::
139
163
Output only the trailers, not any other parts of the input.
140
164
141
165
--only-input::
142
166
Output only trailers that exist in the input; do not add any
143
- from the command-line or by following configured `trailer.*`
144
- rules .
167
+ from the command-line or by applying `trailer.*` configuration
168
+ variables .
145
169
146
170
--unfold::
147
- Remove any whitespace-continuation in trailers, so that each
148
- trailer appears on a line by itself with its full content .
171
+ If a trailer has a value that runs over multiple lines (aka "folded"),
172
+ reformat the value into a single line .
149
173
150
174
--parse::
151
175
A convenience alias for `--only-trailers --only-input
152
- --unfold`.
176
+ --unfold`. This makes it easier to only see the trailers coming from the
177
+ input without influencing them with any command line options or
178
+ configuration variables, while also making the output machine-friendly with
179
+ --unfold.
153
180
154
181
--no-divider::
155
182
Do not treat `---` as the end of the commit message. Use this
@@ -170,11 +197,11 @@ used when another separator is not specified in the config for this
170
197
trailer.
171
198
+
172
199
For example, if the value for this option is "%=$", then only lines
173
- using the format '<token ><sep><value>' with <sep> containing '%', '='
200
+ using the format '<key ><sep><value>' with <sep> containing '%', '='
174
201
or '$' and then spaces will be considered trailers. And '%' will be
175
202
the default separator used, so by default trailers will appear like:
176
- '<token >% <value>' (one percent sign and one space will appear between
177
- the token and the value).
203
+ '<key >% <value>' (one percent sign and one space will appear between
204
+ the key and the value).
178
205
179
206
trailer.where::
180
207
This option tells where a new trailer will be added.
@@ -188,41 +215,41 @@ If it is `start`, then each new trailer will appear at the start,
188
215
instead of the end, of the existing trailers.
189
216
+
190
217
If it is `after`, then each new trailer will appear just after the
191
- last trailer with the same <token >.
218
+ last trailer with the same <key >.
192
219
+
193
220
If it is `before`, then each new trailer will appear just before the
194
- first trailer with the same <token >.
221
+ first trailer with the same <key >.
195
222
196
223
trailer.ifexists::
197
224
This option makes it possible to choose what action will be
198
225
performed when there is already at least one trailer with the
199
- same <token > in the input.
226
+ same <key > in the input.
200
227
+
201
228
The valid values for this option are: `addIfDifferentNeighbor` (this
202
229
is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
203
230
+
204
231
With `addIfDifferentNeighbor`, a new trailer will be added only if no
205
- trailer with the same (<token >, <value>) pair is above or below the line
232
+ trailer with the same (<key >, <value>) pair is above or below the line
206
233
where the new trailer will be added.
207
234
+
208
235
With `addIfDifferent`, a new trailer will be added only if no trailer
209
- with the same (<token >, <value>) pair is already in the input.
236
+ with the same (<key >, <value>) pair is already in the input.
210
237
+
211
238
With `add`, a new trailer will be added, even if some trailers with
212
- the same (<token >, <value>) pair are already in the input.
239
+ the same (<key >, <value>) pair are already in the input.
213
240
+
214
- With `replace`, an existing trailer with the same <token > will be
241
+ With `replace`, an existing trailer with the same <key > will be
215
242
deleted and the new trailer will be added. The deleted trailer will be
216
- the closest one (with the same <token >) to the place where the new one
243
+ the closest one (with the same <key >) to the place where the new one
217
244
will be added.
218
245
+
219
246
With `doNothing`, nothing will be done; that is no new trailer will be
220
- added if there is already one with the same <token > in the input.
247
+ added if there is already one with the same <key > in the input.
221
248
222
249
trailer.ifmissing::
223
250
This option makes it possible to choose what action will be
224
251
performed when there is not yet any trailer with the same
225
- <token > in the input.
252
+ <key > in the input.
226
253
+
227
254
The valid values for this option are: `add` (this is the default) and
228
255
`doNothing`.
@@ -231,64 +258,70 @@ With `add`, a new trailer will be added.
231
258
+
232
259
With `doNothing`, nothing will be done.
233
260
234
- trailer.<token>.key::
235
- This `key` will be used instead of <token> in the trailer. At
236
- the end of this key, a separator can appear and then some
237
- space characters. By default the only valid separator is ':',
238
- but this can be changed using the `trailer.separators` config
239
- variable.
261
+ trailer.<keyAlias>.key::
262
+ Defines a <keyAlias> for the <key>. The <keyAlias> must be a
263
+ prefix (case does not matter) of the <key>. For example, in `git
264
+ config trailer.ack.key "Acked-by"` the "Acked-by" is the <key> and
265
+ the "ack" is the <keyAlias>. This configuration allows the shorter
266
+ `--trailer "ack:..."` invocation on the command line using the "ack"
267
+ <keyAlias> instead of the longer `--trailer "Acked-by:..."`.
268
+ +
269
+ At the end of the <key>, a separator can appear and then some
270
+ space characters. By default the only valid separator is ':',
271
+ but this can be changed using the `trailer.separators` config
272
+ variable.
240
273
+
241
- If there is a separator, then the key will be used instead of both the
242
- <token> and the default separator when adding the trailer.
274
+ If there is a separator in the key, then it overrides the default
275
+ separator when adding the trailer.
243
276
244
- trailer.<token >.where::
277
+ trailer.<keyAlias >.where::
245
278
This option takes the same values as the 'trailer.where'
246
279
configuration variable and it overrides what is specified by
247
- that option for trailers with the specified <token >.
280
+ that option for trailers with the specified <keyAlias >.
248
281
249
- trailer.<token >.ifexists::
282
+ trailer.<keyAlias >.ifexists::
250
283
This option takes the same values as the 'trailer.ifexists'
251
284
configuration variable and it overrides what is specified by
252
- that option for trailers with the specified <token >.
285
+ that option for trailers with the specified <keyAlias >.
253
286
254
- trailer.<token >.ifmissing::
287
+ trailer.<keyAlias >.ifmissing::
255
288
This option takes the same values as the 'trailer.ifmissing'
256
289
configuration variable and it overrides what is specified by
257
- that option for trailers with the specified <token >.
290
+ that option for trailers with the specified <keyAlias >.
258
291
259
- trailer.<token >.command::
260
- Deprecated in favor of 'trailer.<token >.cmd'.
261
- This option behaves in the same way as 'trailer.<token >.cmd', except
292
+ trailer.<keyAlias >.command::
293
+ Deprecated in favor of 'trailer.<keyAlias >.cmd'.
294
+ This option behaves in the same way as 'trailer.<keyAlias >.cmd', except
262
295
that it doesn't pass anything as argument to the specified command.
263
296
Instead the first occurrence of substring $ARG is replaced by the
264
297
<value> that would be passed as argument.
265
298
+
266
299
Note that $ARG in the user's command is
267
300
only replaced once and that the original way of replacing $ARG is not safe.
268
301
+
269
- When both 'trailer.<token >.cmd' and 'trailer.<token >.command' are given
270
- for the same <token >, 'trailer.<token >.cmd' is used and
271
- 'trailer.<token >.command' is ignored.
302
+ When both 'trailer.<keyAlias >.cmd' and 'trailer.<keyAlias >.command' are given
303
+ for the same <keyAlias >, 'trailer.<keyAlias >.cmd' is used and
304
+ 'trailer.<keyAlias >.command' is ignored.
272
305
273
- trailer.<token >.cmd::
306
+ trailer.<keyAlias >.cmd::
274
307
This option can be used to specify a shell command that will be called
275
- once to automatically add a trailer with the specified <token >, and then
276
- called each time a '--trailer <token >=<value>' argument is specified to
308
+ once to automatically add a trailer with the specified <keyAlias >, and then
309
+ called each time a '--trailer <keyAlias >=<value>' argument is specified to
277
310
modify the <value> of the trailer that this option would produce.
278
311
+
279
312
When the specified command is first called to add a trailer
280
- with the specified <token >, the behavior is as if a special
281
- '--trailer <token >=<value>' argument was added at the beginning
313
+ with the specified <keyAlias >, the behavior is as if a special
314
+ '--trailer <keyAlias >=<value>' argument was added at the beginning
282
315
of the "git interpret-trailers" command, where <value>
283
316
is taken to be the standard output of the command with any
284
317
leading and trailing whitespace trimmed off.
285
318
+
286
- If some '--trailer <token >=<value>' arguments are also passed
319
+ If some '--trailer <keyAlias >=<value>' arguments are also passed
287
320
on the command line, the command is called again once for each
288
- of these arguments with the same <token >. And the <value> part
321
+ of these arguments with the same <keyAlias >. And the <value> part
289
322
of these arguments, if any, will be passed to the command as its
290
323
first argument. This way the command can produce a <value> computed
291
- from the <value> passed in the '--trailer <token >=<value>' argument.
324
+ from the <value> passed in the '--trailer <keyAlias >=<value>' argument.
292
325
293
326
EXAMPLES
294
327
--------
0 commit comments