Re: [PATCH v5] attr: teach "--attr-source=<tree>" global option to "git"
- From
Christian Couder <christian.couder@gmail.com>
- Date
- May 4, 2023, 09:50 UTC
- Message-ID
- <CAP8UFD1AuFWWC=iAe0duhpSsw9HnA-tcpV2F3NGT+089aY60Ow@mail.gmail.com>
- In-Reply-To
- <pull.1470.v5.git.git.1683144574158.gitgitgadget@gmail.com>
On Wed, May 3, 2023 at 10:09 PM John Cai via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 17 quoted lines
> @@ -314,6 +315,21 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
> } else {
> exit(list_cmds(cmd));
> }
> + } else if (!strcmp(cmd, "--attr-source")) {
> + if (*argc < 2) {
> + fprintf(stderr, _("no attribute source given for --attr-source\n" ));
> + usage(git_usage_string);
> + }
> + setenv(GIT_ATTR_SOURCE_ENVIRONMENT, (*argv)[1], 1);
> + if (envchanged)
> + *envchanged = 1;
> + (*argv)++;
> + (*argc)--;
> + } else if (skip_prefix(cmd, "--attr-source=", &cmd)) {
> + set_git_attr_source(cmd);
> + setenv(GIT_ATTR_SOURCE_ENVIRONMENT, (*argv)[1], 1);It seems to me that for other options "cmd" is used here instead of "(*argv)[1]" as the second argument to setenv(), for example:
setenv(GIT_SUPER_PREFIX_ENVIRONMENT, cmd, 1);
Show 5 quoted lines
> + if (envchanged)
> + *envchanged = 1;
> } else {
> fprintf(stderr, _("unknown option: %s\n"), cmd);
> usage(git_usage_string);