Skip to content

Commit 6ccbc66

Browse files
Linus Arvergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab76661 commit 6ccbc66

File tree

2 files changed

+77
-61
lines changed

2 files changed

+77
-61
lines changed

Documentation/git-interpret-trailers.txt

Lines changed: 76 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git interpret-trailers' [--in-place] [--trim-empty]
12-
[(--trailer <token>[(=|:)<value>])...]
12+
[(--trailer (<key>|<keyAlias>)[(=|:)<value>])...]
1313
[--parse] [<file>...]
1414

1515
DESCRIPTION
@@ -53,22 +53,32 @@ are applied to each input and the way any existing trailer in
5353
the input is changed. They also make it possible to
5454
automatically add some trailers.
5555

56-
By default, a '<token>=<value>' or '<token>:<value>' argument given
56+
By default, a '<key>=<value>' or '<key>:<value>' argument given
5757
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
6060
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:
6262

6363
------------------------------------------------
64-
token: value
64+
key: value
6565
------------------------------------------------
6666

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"`.
7282

7383
By default the new trailer will appear at the end of all the existing
7484
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
8595
space or the end of the line).
8696

8797
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,
90100
inside or after the <value>. The <value> may be split over multiple lines
91101
with each subsequent line starting with at least one whitespace, like
92102
the "folding" in RFC 822. Example:
93103

94104
------------------------------------------------
95-
token: This is a very long value, with spaces and
105+
key: This is a very long value, with spaces and
96106
newlines in it.
97107
------------------------------------------------
98108

@@ -109,16 +119,16 @@ OPTIONS
109119
the whole trailer will be removed from the output.
110120
This applies to existing trailers as well as new trailers.
111121

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
114124
trailer to the inputs. See the description of this
115125
command.
116126

117127
--where <placement>::
118128
--no-where::
119129
Specify where all new trailers will be added. A setting
120130
provided with '--where' overrides the `trailer.where` and any
121-
applicable `trailer.<token>.where` configuration variables
131+
applicable `trailer.<keyAlias>.where` configuration variables
122132
and applies to all '--trailer' options until the next occurrence of
123133
'--where' or '--no-where'. Upon encountering '--no-where', clear the
124134
effect of any previous use of '--where', such that the relevant configuration
@@ -128,9 +138,9 @@ OPTIONS
128138
--if-exists <action>::
129139
--no-if-exists::
130140
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
132142
provided with '--if-exists' overrides the `trailer.ifExists` and any
133-
applicable `trailer.<token>.ifExists` configuration variables
143+
applicable `trailer.<keyAlias>.ifExists` configuration variables
134144
and applies to all '--trailer' options until the next occurrence of
135145
'--if-exists' or '--no-if-exists'. Upon encountering '--no-if-exists, clear the
136146
effect of any previous use of '--if-exists, such that the relevant configuration
@@ -140,9 +150,9 @@ OPTIONS
140150
--if-missing <action>::
141151
--no-if-missing::
142152
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
144154
provided with '--if-missing' overrides the `trailer.ifMissing` and any
145-
applicable `trailer.<token>.ifMissing` configuration variables
155+
applicable `trailer.<keyAlias>.ifMissing` configuration variables
146156
and applies to all '--trailer' options until the next occurrence of
147157
'--if-missing' or '--no-if-missing'. Upon encountering '--no-if-missing,
148158
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
187197
trailer.
188198
+
189199
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 '%', '='
191201
or '$' and then spaces will be considered trailers. And '%' will be
192202
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).
195205

196206
trailer.where::
197207
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,
205215
instead of the end, of the existing trailers.
206216
+
207217
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>.
209219
+
210220
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>.
212222

213223
trailer.ifexists::
214224
This option makes it possible to choose what action will be
215225
performed when there is already at least one trailer with the
216-
same <token> in the input.
226+
same <key> in the input.
217227
+
218228
The valid values for this option are: `addIfDifferentNeighbor` (this
219229
is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
220230
+
221231
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
223233
where the new trailer will be added.
224234
+
225235
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.
227237
+
228238
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.
230240
+
231-
With `replace`, an existing trailer with the same <token> will be
241+
With `replace`, an existing trailer with the same <key> will be
232242
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
234244
will be added.
235245
+
236246
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.
238248

239249
trailer.ifmissing::
240250
This option makes it possible to choose what action will be
241251
performed when there is not yet any trailer with the same
242-
<token> in the input.
252+
<key> in the input.
243253
+
244254
The valid values for this option are: `add` (this is the default) and
245255
`doNothing`.
@@ -248,64 +258,70 @@ With `add`, a new trailer will be added.
248258
+
249259
With `doNothing`, nothing will be done.
250260

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.
257273
+
258274
If there is a separator in the key, then it overrides the default
259275
separator when adding the trailer.
260276

261-
trailer.<token>.where::
277+
trailer.<keyAlias>.where::
262278
This option takes the same values as the 'trailer.where'
263279
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>.
265281

266-
trailer.<token>.ifexists::
282+
trailer.<keyAlias>.ifexists::
267283
This option takes the same values as the 'trailer.ifexists'
268284
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>.
270286

271-
trailer.<token>.ifmissing::
287+
trailer.<keyAlias>.ifmissing::
272288
This option takes the same values as the 'trailer.ifmissing'
273289
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>.
275291

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
279295
that it doesn't pass anything as argument to the specified command.
280296
Instead the first occurrence of substring $ARG is replaced by the
281297
<value> that would be passed as argument.
282298
+
283299
Note that $ARG in the user's command is
284300
only replaced once and that the original way of replacing $ARG is not safe.
285301
+
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.
289305

290-
trailer.<token>.cmd::
306+
trailer.<keyAlias>.cmd::
291307
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
294310
modify the <value> of the trailer that this option would produce.
295311
+
296312
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
299315
of the "git interpret-trailers" command, where <value>
300316
is taken to be the standard output of the command with any
301317
leading and trailing whitespace trimmed off.
302318
+
303-
If some '--trailer <token>=<value>' arguments are also passed
319+
If some '--trailer <keyAlias>=<value>' arguments are also passed
304320
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
306322
of these arguments, if any, will be passed to the command as its
307323
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.
309325

310326
EXAMPLES
311327
--------

builtin/interpret-trailers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
static const char * const git_interpret_trailers_usage[] = {
1616
N_("git interpret-trailers [--in-place] [--trim-empty]\n"
17-
" [(--trailer <token>[(=|:)<value>])...]\n"
17+
" [(--trailer (<key>|<keyAlias>)[(=|:)<value>])...]\n"
1818
" [--parse] [<file>...]"),
1919
NULL
2020
};

0 commit comments

Comments
 (0)