99--------
1010[verse]
1111'git interpret-trailers' [--in-place] [--trim-empty]
12- [(--trailer <token> [(=|:)<value>])...]
12+ [(--trailer (<key>|<keyAlias>) [(=|:)<value>])...]
1313 [--parse] [<file>...]
1414
1515DESCRIPTION
@@ -31,10 +31,15 @@ the last two lines starting with "Signed-off-by" are trailers.
3131
3232This command reads commit messages from either the
3333<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.
3843
3944This command can also operate on the output of linkgit:git-format-patch[1],
4045which 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
4853the input is changed. They also make it possible to
4954automatically add some trailers.
5055
51- By default, a '<token >=<value>' or '<token >:<value>' argument given
56+ By default, a '<key >=<value>' or '<key >:<value>' argument given
5257using `--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
5560to 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:
5762
5863------------------------------------------------
59- token : value
64+ key : value
6065------------------------------------------------
6166
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"`.
6782
6883By default the new trailer will appear at the end of all the existing
6984trailers. 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
8095space or the end of the line).
8196
8297When 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,
85100inside or after the <value>. The <value> may be split over multiple lines
86101with each subsequent line starting with at least one whitespace, like
87102the "folding" in RFC 822. Example:
88103
89104------------------------------------------------
90- token : This is a very long value, with spaces and
105+ key : This is a very long value, with spaces and
91106 newlines in it.
92107------------------------------------------------
93108
@@ -104,52 +119,64 @@ OPTIONS
104119 the whole trailer will be removed from the output.
105120 This applies to existing trailers as well as new trailers.
106121
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
109124 trailer to the inputs. See the description of this
110125 command.
111126
112127--where <placement>::
113128--no-where::
114129 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
116132 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`.
119137
120138--if-exists <action>::
121139--no-if-exists::
122140 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
125144 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`,
127148 `addIfDifferentNeighbor`, `add`, `replace` and `doNothing`.
128149
129150--if-missing <action>::
130151--no-if-missing::
131152 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
134156 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`
136160 or `add`.
137161
138162--only-trailers::
139163 Output only the trailers, not any other parts of the input.
140164
141165--only-input::
142166 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 .
145169
146170--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 .
149173
150174--parse::
151175 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.
153180
154181--no-divider::
155182 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
170197trailer.
171198+
172199For 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 '%', '='
174201or '$' and then spaces will be considered trailers. And '%' will be
175202the 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).
178205
179206trailer.where::
180207 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,
188215instead of the end, of the existing trailers.
189216+
190217If 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 >.
192219+
193220If 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 >.
195222
196223trailer.ifexists::
197224 This option makes it possible to choose what action will be
198225 performed when there is already at least one trailer with the
199- same <token > in the input.
226+ same <key > in the input.
200227+
201228The valid values for this option are: `addIfDifferentNeighbor` (this
202229is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
203230+
204231With `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
206233where the new trailer will be added.
207234+
208235With `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.
210237+
211238With `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.
213240+
214- With `replace`, an existing trailer with the same <token > will be
241+ With `replace`, an existing trailer with the same <key > will be
215242deleted 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
217244will be added.
218245+
219246With `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.
221248
222249trailer.ifmissing::
223250 This option makes it possible to choose what action will be
224251 performed when there is not yet any trailer with the same
225- <token > in the input.
252+ <key > in the input.
226253+
227254The valid values for this option are: `add` (this is the default) and
228255`doNothing`.
@@ -231,64 +258,70 @@ With `add`, a new trailer will be added.
231258+
232259With `doNothing`, nothing will be done.
233260
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.
240273+
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.
243276
244- trailer.<token >.where::
277+ trailer.<keyAlias >.where::
245278 This option takes the same values as the 'trailer.where'
246279 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 >.
248281
249- trailer.<token >.ifexists::
282+ trailer.<keyAlias >.ifexists::
250283 This option takes the same values as the 'trailer.ifexists'
251284 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 >.
253286
254- trailer.<token >.ifmissing::
287+ trailer.<keyAlias >.ifmissing::
255288 This option takes the same values as the 'trailer.ifmissing'
256289 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 >.
258291
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
262295 that it doesn't pass anything as argument to the specified command.
263296 Instead the first occurrence of substring $ARG is replaced by the
264297 <value> that would be passed as argument.
265298+
266299Note that $ARG in the user's command is
267300only replaced once and that the original way of replacing $ARG is not safe.
268301+
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.
272305
273- trailer.<token >.cmd::
306+ trailer.<keyAlias >.cmd::
274307 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
277310 modify the <value> of the trailer that this option would produce.
278311+
279312When 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
282315of the "git interpret-trailers" command, where <value>
283316is taken to be the standard output of the command with any
284317leading and trailing whitespace trimmed off.
285318+
286- If some '--trailer <token >=<value>' arguments are also passed
319+ If some '--trailer <keyAlias >=<value>' arguments are also passed
287320on 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
289322of these arguments, if any, will be passed to the command as its
290323first 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.
292325
293326EXAMPLES
294327--------
0 commit comments