Re: [PATCH v4] attr: teach "--attr-source=<tree>" global option to "git"

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

 



On Sun, Apr 30, 2023 at 4:39 AM John Cai via GitGitGadget
<gitgitgadget@xxxxxxxxx> wrote:

> diff --git a/Documentation/git.txt b/Documentation/git.txt
> index 74973d3cc40..b8f4f604707 100644
> --- a/Documentation/git.txt
> +++ b/Documentation/git.txt
> @@ -212,6 +212,11 @@ If you just want to run git as if it was started in `<path>` then use
>         nohelpers (exclude helper commands), alias and config
>         (retrieve command list from config variable completion.commands)
>
> +--attr-source=<tree-ish>::
> +       Read gitattributes from <tree-ish> instead of the worktree. See
> +       linkgit:gitattributes[5]. This is equivalent to setting the
> +       `GIT_ATTR_SOURCE` environment variable.

As you talk about GIT_ATTR_SOURCE, I wonder if this variable should
also be documented in the "Environment Variables" section of this
Documentation/git.txt doc.

> diff --git a/environment.h b/environment.h
> index a63f0c6a24f..758927a689c 100644
> --- a/environment.h
> +++ b/environment.h
> @@ -55,6 +55,7 @@ const char *getenv_safe(struct strvec *argv, const char *name);
>  #define GIT_QUARANTINE_ENVIRONMENT "GIT_QUARANTINE_PATH"
>  #define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS"
>  #define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT "GIT_TEXTDOMAINDIR"
> +#define GIT_ATTR_SOURCE "GIT_ATTR_SOURCE"

To be similar with the definitions that are just above, I think it
actually should be:

#define GIT_ATTR_SOURCE_ENVIRONMENT "GIT_ATTR_SOURCE"

> @@ -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 prefix given for --attr-source\n" ));

The example I sent was about '--super-prefix' so it made sense to say
"no prefix given", but here it makes more sense to say something like
"no attribute source given for --attr-source".

> +                               usage(git_usage_string);
> +                       }
> +                       setenv(GIT_ATTR_SOURCE, (*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, (*argv)[1], 1);
> +                       if (envchanged)
> +                               *envchanged = 1;
>                 } else {
>                         fprintf(stderr, _("unknown option: %s\n"), cmd);
>                         usage(git_usage_string);




[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