Subject: Re: [PATCH v10 2/2] [GSOC] trailer: add new .cmd config option

From: Junio C Hamano <[email-masked]>
Date: Fri, 16 Apr 2021 12:21:34 -0700

"ZheNing Hu via GitGitGadget" <[email-masked]> writes:

> Introduce a new `trailer.<token>.cmd` configuration that
> takes higher precedence to deprecate and eventually remove
> `trailer.<token>.command`, which passes the value as an
> argument to the command.  Instead of "$ARG", users can
> refer to the value as positional argument, $1, in their
> scripts. At the same time, in order to allow
> `git interpret-trailers` to better simulate the behavior
> of `git command -s`, 'trailer.<token>.cmd' will not
> automatically execute.

OK.  I think there still will be disagreement on this last point
between Christian and I, but I'd be happy with this as the first cut
for newly introduced .cmd and then when it becomes needed add
something like the attached patch on top to optionally run the given
command when configured.

 trailer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git c/trailer.c w/trailer.c
index 7c7cb61a94..39132211cc 100644
--- c/trailer.c
+++ w/trailer.c
@@ -723,7 +723,8 @@ static void process_command_line_args(struct list_head *arg_head,
 	/* Add an arg item for each configured trailer with a command */
 	list_for_each(pos, &conf_head) {
 		item = list_entry(pos, struct arg_item, list);
-		if (item->conf.command)
+		if ((item->conf.run_implicitly && item->conf.cmd) ||
+		    item->conf.command)
 			add_arg_item(arg_head,
 				     xstrdup(token_from_item(item, NULL)),
 				     xstrdup(""),