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

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

From
Christian Couder <christian.couder@gmail.com>
Date
Jun 9, 2026, 10:20 UTC
Message-ID
<CAP8UFD2vhb3fMp0sfJKewYm8H7HQQ5+dZnQFijDL4Z5Mcf3SCQ@mail.gmail.com>
In-Reply-To
<20260606143412.15443-1-cat@malon.dev>

"environment.c:" in the subject could be replaced by just "environment:". It's a bit shorter and it better describes the area of the code where the main changes are made, as changes are not just made in "environment.c" but also in "environment.h".

On Sat, Jun 6, 2026 at 4:34 PM Tian Yuchen <cat@malon.dev> wrote:
Show 13 quoted lines
>
> Move the global 'protect_hfs' and 'protect_ntfs' configurations
> into the repository-specific 'repo_config_values' struct.
> This will help with the elimination of 'the_repository'
>
> For now, associated functions access this configuration by
> explicitly falling back to 'the_repository', which needs to
> be addressed in the future.
>
> Note: In 't/helper/test-path-utils.c', there is a function
> 'protect_ntfs_hfs_benchmark()' where these two global
> variables are used as loop iterators. New local variables
> have been created to replace them.
Show 11 quoted lines
> diff --git a/compat/mingw.c b/compat/mingw.c
> index aa7525f419..c77696ba8a 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -3392,7 +3392,7 @@ int is_valid_win32_path(const char *path, int allow_literal_nul)
>         const char *p = path;
>         int preceding_space_or_period = 0, i = 0, periods = 0;
>
> -       if (!protect_ntfs)
> +       if (!(the_repository->gitdir ? repo_config_values(the_repository)->protect_ntfs : 1))
>                 return 1;
I think the code would benefit from functions like:
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;
}

They could be called by passing `the_repository` for now, but perhaps later in future commits `istate->repo` or something like that could be passed instead. Also a code comment could explain that the `gitdir` check prevents calling `repo_config_values()` before config is loaded.

Thanks.
Previous: Christian CouderNext: Tian Yuchen
Message 4 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.