Re: [PATCH v13] [GSOC] commit: add --trailer option
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Mar 23, 2021, 12:41 UTC
- Message-ID
- <CAP8UFD2v=q45u_jttHmff_1=rBCANmam_-HbNE5Fg=SnhZ_3Hg@mail.gmail.com>
- In-Reply-To
- <CAOLTT8TKqDWnu3k1Xz=qBhmdZYFhM452WzVGG=OArgJL3z0yGQ@mail.gmail.com>
On Tue, Mar 23, 2021 at 11:35 AM ZheNing Hu <adlternative@gmail.com> wrote:
> > Junio C Hamano <gitster@pobox.com> 于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.
Show 18 quoted lines
> 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.Show 5 quoted lines
> strvec_push(&cp.args, cmd.buf); > - cp.env = local_repo_env; > + > cp.no_stdin = 1; > cp.use_shell = 1;
Thanks!