trailer doc: <token> is a <key> or <keyAlias>, not both
The `--trailer` option takes a "<token>=<value>" argument, for example --trailer "Acked-by=Bob" And in this exampple it is understood that "Acked-by" is the <token>. However, the user can use a shorter "ack" string by defining configuration like git config trailer.ack.key "Acked-by" However, in the docs we define the above configuration as trailer.<token>.key so the <token> can mean either the longer "Acked-by" or the shorter "ack". Separate the two meanings of <token> into <key> and <keyAlias>, and update the configuration syntax to say "trailer.<keyAlias>.key". Signed-off-by: Linus Arver <linusa@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Linus Arver committed
Sep 7, 2023 at 22:20 UTC
6ccbc6679426e39720278aedbb8e415dac8db79b
2 files changed
+77
-61
Documentation/git-interpret-trailers.txt
+76
-60
@@ -9,7 +9,7 @@ SYNOPSIS
9
--------
10
[verse]
11
'git interpret-trailers' [--in-place] [--trim-empty]
12
- [(--trailer <token>[(=|:)<value>])...]
12
+ [(--trailer (<key>|<keyAlias>)[(=|:)<value>])...]
13
[--parse] [<file>...]
14
15
DESCRIPTION
@@ -53,22 +53,32 @@ are applied to each input and the way any existing trailer in
53
the input is changed. They also make it possible to
54
automatically add some trailers.
55
56
-By default, a '<token>=<value>' or '<token>:<value>' argument given
56
+By default, a '<key>=<value>' or '<key>:<value>' argument given
57
using `--trailer` will be appended after the existing trailers only if
58
-the last trailer has a different (<token>, <value>) pair (or if there
59
-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
60
to remove starting and trailing whitespace, and the resulting trimmed
61
-<token> and <value> will appear in the output like this:
61
+<key> and <value> will appear in the output like this:
62
63
------------------------------------------------
64
-token: value
64
+key: value
65
------------------------------------------------
66
67
-This means that the trimmed <token> and <value> will be separated by
68
-`': '` (one colon followed by one space). For convenience, the <token> can be a
69
-shortened string key (e.g., "sign") instead of the full string which should
70
-appear before the separator on the output (e.g., "Signed-off-by"). This can be
71
-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"`.
82
83
By default the new trailer will appear at the end of all the existing
84
trailers. If there is no existing trailer, the new trailer will appear
@@ -85,14 +95,14 @@ non-whitespace lines before a line that starts with '---' (followed by a
95
space or the end of the line).
96
97
When reading trailers, there can be no whitespace before or inside the
88
-<token>, but any number of regular space and tab characters are allowed
89
-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,
100
inside or after the <value>. The <value> may be split over multiple lines
101
with each subsequent line starting with at least one whitespace, like
102
the "folding" in RFC 822. Example:
103
104
------------------------------------------------
95
-token: This is a very long value, with spaces and
105
+key: This is a very long value, with spaces and
106
newlines in it.
107
------------------------------------------------
108
@@ -109,8 +119,8 @@ OPTIONS
119
the whole trailer will be removed from the output.
120
This applies to existing trailers as well as new trailers.
121
112
---trailer <token>[(=|:)<value>]::
113
- 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
124
trailer to the inputs. See the description of this
125
command.
126
@@ -118,7 +128,7 @@ OPTIONS
128
--no-where::
129
Specify where all new trailers will be added. A setting
130
provided with '--where' overrides the `trailer.where` and any
121
- applicable `trailer.<token>.where` configuration variables
131
+ applicable `trailer.<keyAlias>.where` configuration variables
132
and applies to all '--trailer' options until the next occurrence of
133
'--where' or '--no-where'. Upon encountering '--no-where', clear the
134
effect of any previous use of '--where', such that the relevant configuration
@@ -128,9 +138,9 @@ OPTIONS
138
--if-exists <action>::
139
--no-if-exists::
140
Specify what action will be performed when there is already at
131
- least one trailer with the same <token> in the input. A setting
141
+ least one trailer with the same <key> in the input. A setting
142
provided with '--if-exists' overrides the `trailer.ifExists` and any
133
- applicable `trailer.<token>.ifExists` configuration variables
143
+ applicable `trailer.<keyAlias>.ifExists` configuration variables
144
and applies to all '--trailer' options until the next occurrence of
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
@@ -140,9 +150,9 @@ OPTIONS
150
--if-missing <action>::
151
--no-if-missing::
152
Specify what action will be performed when there is no other
143
- trailer with the same <token> in the input. A setting
153
+ trailer with the same <key> in the input. A setting
154
provided with '--if-missing' overrides the `trailer.ifMissing` and any
145
- applicable `trailer.<token>.ifMissing` configuration variables
155
+ applicable `trailer.<keyAlias>.ifMissing` configuration variables
156
and applies to all '--trailer' options until the next occurrence of
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
@@ -187,11 +197,11 @@ used when another separator is not specified in the config for this
197
trailer.
198
+
199
For example, if the value for this option is "%=$", then only lines
190
-using the format '<token><sep><value>' with <sep> containing '%', '='
200
+using the format '<key><sep><value>' with <sep> containing '%', '='
201
or '$' and then spaces will be considered trailers. And '%' will be
202
the default separator used, so by default trailers will appear like:
193
-'<token>% <value>' (one percent sign and one space will appear between
194
-the token and the value).
203
+'<key>% <value>' (one percent sign and one space will appear between
204
+the key and the value).
205
206
trailer.where::
207
This option tells where a new trailer will be added.
@@ -205,41 +215,41 @@ If it is `start`, then each new trailer will appear at the start,
215
instead of the end, of the existing trailers.
216
+
217
If it is `after`, then each new trailer will appear just after the
208
-last trailer with the same <token>.
218
+last trailer with the same <key>.
219
+
220
If it is `before`, then each new trailer will appear just before the
211
-first trailer with the same <token>.
221
+first trailer with the same <key>.
222
223
trailer.ifexists::
224
This option makes it possible to choose what action will be
225
performed when there is already at least one trailer with the
216
- same <token> in the input.
226
+ same <key> in the input.
227
+
228
The valid values for this option are: `addIfDifferentNeighbor` (this
229
is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
230
+
231
With `addIfDifferentNeighbor`, a new trailer will be added only if no
222
-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
233
where the new trailer will be added.
234
+
235
With `addIfDifferent`, a new trailer will be added only if no trailer
226
-with the same (<token>, <value>) pair is already in the input.
236
+with the same (<key>, <value>) pair is already in the input.
237
+
238
With `add`, a new trailer will be added, even if some trailers with
229
-the same (<token>, <value>) pair are already in the input.
239
+the same (<key>, <value>) pair are already in the input.
240
+
231
-With `replace`, an existing trailer with the same <token> will be
241
+With `replace`, an existing trailer with the same <key> will be
242
deleted and the new trailer will be added. The deleted trailer will be
233
-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
244
will be added.
245
+
246
With `doNothing`, nothing will be done; that is no new trailer will be
237
-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.
248
249
trailer.ifmissing::
250
This option makes it possible to choose what action will be
251
performed when there is not yet any trailer with the same
242
- <token> in the input.
252
+ <key> in the input.
253
+
254
The valid values for this option are: `add` (this is the default) and
255
`doNothing`.
@@ -248,34 +258,40 @@ With `add`, a new trailer will be added.
258
+
259
With `doNothing`, nothing will be done.
260
251
-trailer.<token>.key::
252
- This `key` will be used instead of <token> in the trailer. At
253
- the end of this key, a separator can appear and then some
254
- space characters. By default the only valid separator is ':',
255
- but this can be changed using the `trailer.separators` config
256
- 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.
273
+
274
If there is a separator in the key, then it overrides the default
275
separator when adding the trailer.
276
261
-trailer.<token>.where::
277
+trailer.<keyAlias>.where::
278
This option takes the same values as the 'trailer.where'
279
configuration variable and it overrides what is specified by
264
- that option for trailers with the specified <token>.
280
+ that option for trailers with the specified <keyAlias>.
281
266
-trailer.<token>.ifexists::
282
+trailer.<keyAlias>.ifexists::
283
This option takes the same values as the 'trailer.ifexists'
284
configuration variable and it overrides what is specified by
269
- that option for trailers with the specified <token>.
285
+ that option for trailers with the specified <keyAlias>.
286
271
-trailer.<token>.ifmissing::
287
+trailer.<keyAlias>.ifmissing::
288
This option takes the same values as the 'trailer.ifmissing'
289
configuration variable and it overrides what is specified by
274
- that option for trailers with the specified <token>.
290
+ that option for trailers with the specified <keyAlias>.
291
276
-trailer.<token>.command::
277
- Deprecated in favor of 'trailer.<token>.cmd'.
278
- 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
295
that it doesn't pass anything as argument to the specified command.
296
Instead the first occurrence of substring $ARG is replaced by the
297
<value> that would be passed as argument.
@@ -283,29 +299,29 @@ trailer.<token>.command::
299
Note that $ARG in the user's command is
300
only replaced once and that the original way of replacing $ARG is not safe.
301
+
286
-When both 'trailer.<token>.cmd' and 'trailer.<token>.command' are given
287
-for the same <token>, 'trailer.<token>.cmd' is used and
288
-'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.
305
290
-trailer.<token>.cmd::
306
+trailer.<keyAlias>.cmd::
307
This option can be used to specify a shell command that will be called
292
- once to automatically add a trailer with the specified <token>, and then
293
- 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
310
modify the <value> of the trailer that this option would produce.
311
+
312
When the specified command is first called to add a trailer
297
-with the specified <token>, the behavior is as if a special
298
-'--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
315
of the "git interpret-trailers" command, where <value>
316
is taken to be the standard output of the command with any
317
leading and trailing whitespace trimmed off.
318
+
303
-If some '--trailer <token>=<value>' arguments are also passed
319
+If some '--trailer <keyAlias>=<value>' arguments are also passed
320
on the command line, the command is called again once for each
305
-of these arguments with the same <token>. And the <value> part
321
+of these arguments with the same <keyAlias>. And the <value> part
322
of these arguments, if any, will be passed to the command as its
323
first argument. This way the command can produce a <value> computed
308
-from the <value> passed in the '--trailer <token>=<value>' argument.
324
+from the <value> passed in the '--trailer <keyAlias>=<value>' argument.
325
326
EXAMPLES
327
--------
builtin/interpret-trailers.c
+1
-1
@@ -14,7 +14,7 @@
14
15
static const char * const git_interpret_trailers_usage[] = {
16
N_("git interpret-trailers [--in-place] [--trim-empty]\n"
17
- " [(--trailer <token>[(=|:)<value>])...]\n"
17
+ " [(--trailer (<key>|<keyAlias>)[(=|:)<value>])...]\n"
18
" [--parse] [<file>...]"),
19
NULL
20
};