docs: correct descript of trailer.<token>.command

In the original documentation of `trailer.<token>.command`,
some descriptions are easily misunderstood. So let's modify
it to increase its readability.

In addition, clarify that `$ARG` in command can only be
replaced once.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
ZheNing Hu 2021-05-03 15:41:04 +00:00 committed by Junio C Hamano
parent 2daae3d1d1
commit 57dcb6575b
1 changed files with 21 additions and 16 deletions

View File

@ -232,25 +232,30 @@ trailer.<token>.ifmissing::
that option for trailers with the specified <token>. that option for trailers with the specified <token>.


trailer.<token>.command:: trailer.<token>.command::
This option can be used to specify a shell command that will This option can be used to specify a shell command that will be called:
be called to automatically add or modify a trailer with the once to automatically add a trailer with the specified <token>, and then
specified <token>. each time a '--trailer <token>=<value>' argument to modify the <value> of
the trailer that this option would produce.
+ +
When this option is specified, the behavior is as if a special When the specified command is first called to add a trailer
'<token>=<value>' argument were added at the beginning of the command with the specified <token>, the behavior is as if a special
line, where <value> is taken to be the standard output of the '--trailer <token>=<value>' argument was added at the beginning
specified command with any leading and trailing whitespace trimmed of the "git interpret-trailers" command, where <value>
off. is taken to be the standard output of the command with any
leading and trailing whitespace trimmed off.
+ +
If the command contains the `$ARG` string, this string will be If some '--trailer <token>=<value>' arguments are also passed
replaced with the <value> part of an existing trailer with the same on the command line, the command is called again once for each
<token>, if any, before the command is launched. of these arguments with the same <token>. And the <value> part
of these arguments, if any, will be used to replace the first
occurrence of substring `$ARG` in the command. This way the
command can produce a <value> computed from the <value> passed
in the '--trailer <token>=<value>' argument.
+ +
If some '<token>=<value>' arguments are also passed on the command For consistency, the first occurrence of substring `$ARG` is
line, when a 'trailer.<token>.command' is configured, the command will also replaced, this time with the empty string, in the command
also be executed for each of these arguments. And the <value> part of when the command is first called to add a trailer with the
these arguments, if any, will be used to replace the `$ARG` string in specified <token>.
the command.


EXAMPLES EXAMPLES
-------- --------