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

Re: [PATCH v2 1/1] environment.c: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values'

From
Christian Couder <christian.couder@gmail.com>
Date
Jun 12, 2026, 07:22 UTC
Message-ID
<CAP8UFD1UbsXu_7DK2keGLUO3Yh06-YHieZP+On-yjY3SmV2Xmg@mail.gmail.com>
In-Reply-To
<xmqqse6uwdnz.fsf@gitster.g>
On Wed, Jun 10, 2026 at 6:41 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 40 quoted lines
>
> Tian Yuchen <cat@malon.dev> writes:
>
> > +int repo_protect_ntfs(struct repository *repo)
> > +{
> > +     return repo->gitdir ?
> > +             repo_config_values(repo)->protect_ntfs :
> > +             PROTECT_NTFS_DEFAULT;
> > +}
> > +
> > +int repo_protect_hfs(struct repository *repo)
> > +{
> > +     return repo->gitdir ?
> > +             repo_config_values(repo)->protect_hfs :
> > +             PROTECT_HFS_DEFAULT;
> > +}
> > ...
> > @@ -123,6 +125,14 @@ int git_default_config(const char *, const char *,
> >  int git_default_core_config(const char *var, const char *value,
> >                           const struct config_context *ctx, void *cb);
> >
> > +/*
> > + * Getters for the `protect_hfs` and `protect_ntfs` fields of `struct repo_config_values`.
> > + * They check `repo->gitdir` to prevent calling repo_config_values()
> > + * before the configuration is loaded or in bare environments.
> > + */
> > +int repo_protect_hfs(struct repository *repo);
> > +int repo_protect_ntfs(struct repository *repo);
>
> I briefly wondered what *should* happen when repo->gitdir is not
> ready, as it feels almost a bug for a caller to call these two
> functions before the repository is ready to be used.
>
> When repo is not ready, these return their respective default
> values.  That's like the original code using the initial value of
> these global variables.
>
> IOW, this rewrite is bug-for-bug compatible, which is good.
>
> Shall we declare victory and mark the topic for 'next' now?

I would have preferred the commit subject to start with "environment:" rather than "environment.c:" but it's a small nit and maybe you can fix it while merging.

Otherwise the patch looks indeed good to me.
Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 11 in “environment.c: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values'”
  1. 1/1 environment.c: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values'Tian Yuchen, Jun 6, 2026
  2. 0/1 environment: move protect_hfs and protect_ntfsTian Yuchen, Jun 6, 2026
  3. Christian CouderJun 9, 2026
  4. Christian CouderJun 9, 2026
  5. 0/1 environment: move protect_hfs and protect_ntfs into repo_config_valuesTian Yuchen, Jun 10, 2026
  6. 1/1 environment.c: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values'Tian Yuchen, Jun 10, 2026
  7. Junio C HamanoJun 10, 2026
  8. Christian CouderJun 12, 2026
  9. Junio C HamanoJun 12, 2026
  10. 0/1 environment: move protect_hfs and protect_ntfs into repo_config_valuesTian Yuchen, Jun 13, 2026
  11. 1/1 environment: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values'Tian Yuchen, Jun 13, 2026

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.