Re: [PATCH v13] [GSOC] commit: add --trailer option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 23, 2021 at 11:35 AM ZheNing Hu <adlternative@xxxxxxxxx> wrote:
>
> Junio C Hamano <gitster@xxxxxxxxx> 于2021年3月23日周二 下午2:19写道:

> Maybe like this?

Yeah, it's a good idea to work on this, but please make it an
independent patch unrelated to adding --trailer to `git commit`.

Also the documentation might need a bit of tweeking to tell that ARG
is now an exported environment variable.

> -#define TRAILER_ARG_STRING "$ARG"

It might still be better to use a #define or a const char [] to avoid
hard coding "ARG" below.

> static const char *git_generated_prefixes[] = {
>        "Signed-off-by: ",
>        "(cherry picked from commit ",
> @@ -222,13 +220,17 @@ static char *apply_command(const char *command,
> const char *arg)
>        struct strbuf buf = STRBUF_INIT;
>        struct child_process cp = CHILD_PROCESS_INIT;
>        char *result;
> +       const char *const *var;
>
>        strbuf_addstr(&cmd, command);
> -       if (arg)
> -               strbuf_replace(&cmd, TRAILER_ARG_STRING, arg);
> +       for (var = local_repo_env; *var; var++)
> +               strvec_push(&cp.env_array, *var);
> +       if (arg) {
> +               strvec_pushf(&cp.env_array, "ARG=%s", arg);
> +       }

You can drop the "{" and "}" above.

>        strvec_push(&cp.args, cmd.buf);
> -       cp.env = local_repo_env;
> +
>        cp.no_stdin = 1;
>        cp.use_shell = 1;

Thanks!




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux