Subject: Re: [PATCH v4] [GSOC]trailer: pass arg as positional parameter

From: Junio C Hamano <[email-masked]>
Date: Thu, 01 Apr 2021 12:49:00 -0700

ZheNing Hu <[email-masked]> writes:

>> The way to do the same without an extra script on disk is for you to
>> use sh-c yourself.
>>
>>     .cmd = sh -c 'echo 123'
>
> This is indeed a viable solution, But the extra "sh -c" seems to put an
> unnecessary burden on the user.

Nobody forces you to write long script in the configuration file.
In fact, the "find author from history" is so useful that I'd think
people have an alias or a script in ~/bin/ already for their own
interactive use.  E.g.

    $ cat ~/bin/git-who
    #!/bin/sh
    git log -1 --format="%an <%ae>" --author="$1"
    $ cat ~/bin/git-one
    #!/bin/sh
    git show -s --pretty=reference "$1"

and with them:

	trailer.key.cmd = git who

that is internally wrapped into 

	sh -c 'git who "$@"'

and fed "gitster@" as the first parameter when "--trailer=key:gitster@"
is given would work just fine.

> Sometimes I wonder, why not recommend using environment variables
> like $ARG?

I am also fine with that; when we discovered the design flaw of
.command, I think I suggested either would make a viable choice.
The only downside is that it would squat on a good name $ARG and
forbids end-users from using the symbol for other purpose, but as
long as the application is limited in scope, that would be fine.