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

Re: [PATCH v1 0/1] environment: move protect_hfs and protect_ntfs

From
Christian Couder <christian.couder@gmail.com>
Date
Jun 9, 2026, 10:54 UTC
Message-ID
<CAP8UFD35Tiy1_fqpjq8P-z=ZhzR3MTiThqfCs977652umRoSEQ@mail.gmail.com>
In-Reply-To
<20260606143412.15443-2-cat@malon.dev>
On Sat, Jun 6, 2026 at 4:35 PM Tian Yuchen <cat@malon.dev> wrote:
Show 25 quoted lines
>
> Hi everyone,
>
> This series continues the ongoing libification effort by moving the
> global **filesystem** variables, protect_hfs and protect_ntfs, into
> struct repo_config_values.
>
> Place them within the **per-repository** configuration structure
> aligns with our goal of removing global states.
>
> RFC Questions:
>
> 1. Should we keep PROTECT_HFS_DEFAULT and PROTECT_NTFS_DEFAULT
> in repo_config_values_init()?
>
>         void repo_config_values_init(struct repo_config_values *cfg)
>                 {
>                         cfg->attributes_file = NULL;
>                         cfg->apply_sparse_checkout = 0;
>                         cfg->protect_hfs = PROTECT_HFS_DEFAULT;
>                         cfg->protect_ntfs = PROTECT_NTFS_DEFAULT;
>                         cfg->branch_track = BRANCH_TRACK_REMOTE;
>                 }
>
> Or is it better if they are used anywhere other than in environment.c?

I think it's better to keep them in "environment.c". The repo_protect_ntfs() and repo_protect_hfs() function I suggest adding to "environment.c" in my reply to the patch should help with keeping the macros in "environment.c".

> If so...
> 2. Is it worth introducing a Macro or Getter for safe access?
>
>         ((the_repository->gitdir ? repo_config_values(the_repository)->protect_hfs : 0))
Yes, it seems to me that a getter is enough.
Show 11 quoted lines
> The current approach looks verbose and lacks readability, and
> hard-coded 0 and 1 are used as fallback values. I wonder if a macro or a
> getter could be introduced, for example...
>
>         #define SAFE_PROTECT_HFS(repo) \
>                 (((repo) && (repo)->gitdir && (repo) == the_repository) ? \
>                 repo_config_values(repo)->protect_hfs : PROTECT_HFS_DEFAULT)
>
> ...to improve the coding style a bit. Although I am aware that introducing
> new macros is generally frowned upon, I would still like to know which
> parts this might make difficult to maintain.

Unless there are features that we really want which a function can't provide, a function is better as it provides type safety and is usually easier to maintain.

Show 7 quoted lines
> 3. Note that Derrick attempted to use get_int_config_global to wrap
> this kind of Filesystem Level global variables. This approach bypassed
> struct repository, did not actually eliminate global state, and the
> reviewer politely rejected it. Nevertheless, I am still curious as
> to whether this approach might still be inspiring today.
>
> https://lore.kernel.org/git/a42dd9397d07b2dc4a0d7e75bfe1af2e46cad262.1685716420.git.gitgitgadget@gmail.com/

To help your reviewers, it might be interesting if you could already tell why this was rejected by Glen Choo (who reviewed Derrick Stolee's work then). It seems to me that Glen said that using plain fields in a struct should be better as long as the fields are always initialized during the setup process.

And it seems to me that our patch follows the direction that Glen suggested.
Thanks.
Previous: Tian YuchenNext: Christian Couder
Message 3 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.