git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Christian Couder <christian.couder@gmail.com>
Date
May 3, 2023, 15:10 UTC
Message-ID
<CAP8UFD00omU=HiGQyaNx=ZbuH79rCv-eHkCuQ1sf5xv9zu4ffg@mail.gmail.com>
In-Reply-To
<pull.1470.v4.git.git.1682822352360.gitgitgadget@gmail.com>

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

Show 12 quoted lines
> 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.

Show 9 quoted lines
> 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"
Show 7 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 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".

Show 15 quoted lines
> +                               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);
Previous: Junio C HamanoNext: John Cai
Message 12 of 16 in “attr: teach "--attr-source=<tree>" global option to "git"”
  1. attr: teach "--attr-source=<tree>" global option to "git"John Cai via GitGitGadget, Mar 18, 2023
  2. attr: teach "--attr-source=<tree>" global option to "git"John Cai via GitGitGadget, Mar 27, 2023
  3. Junio C HamanoMar 27, 2023
  4. John CaiMar 27, 2023
  5. Christian CouderApr 27, 2023
  6. Christian CouderApr 27, 2023
  7. attr: teach "--attr-source=<tree>" global option to "git"John Cai via GitGitGadget, Apr 28, 2023
  8. Christian CouderApr 28, 2023
  9. John CaiApr 30, 2023
  10. attr: teach "--attr-source=<tree>" global option to "git"John Cai via GitGitGadget, Apr 30, 2023
  11. Junio C HamanoMay 1, 2023
  12. Christian CouderMay 3, 2023
  13. John CaiMay 3, 2023
  14. attr: teach "--attr-source=<tree>" global option to "git"John Cai via GitGitGadget, May 3, 2023
  15. Christian CouderMay 4, 2023
  16. attr: teach "--attr-source=<tree>" global option to "git"John Cai via GitGitGadget, May 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.