Skip to content

pr-913/adlternative/trailer-pass-ARG-env-v3

From: ZheNing Hu <adlternative@gmail.com>

Original implementation of `trailer.<token>.command` use
`strbuf_replace` to replace $ARG in command with the <value>
of the trailer, but it have a problem: `strbuf_replace`
replace the $ARG only once, If the user's trailer command
have used more than one $ARG, the remaining replacement will
fail.

If directly modify the implementation of the original
`trailer.<token>.command`, The user’s previous `'$ARG'` in
trailer command will not be replaced. So now add new config
"trailer.<token>.cmd", pass trailer's value as positional
parameter 1 to the user's command, the user can use $1 as
trailer's value, to implement original variable replacement.

If the user has these two configuration: "trailer.<token>.cmd"
and "trailer.<token>.command", "cmd" will execute and "command"
will not executed.

Original `trailer.<token>.command` can still be used until git
completely abandoned it.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>

Submitted-As: https://lore.kernel.org/git/pull.913.v3.git.1616673200809.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.913.git.1616511182942.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.913.v2.git.1616600555906.gitgitgadget@gmail.com
Assets 2