From: Christian Couder Date: Tue, 09 Jun 2026 10:20:10 GMT Subject: Re: [PATCH v1 1/1] environment.c: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values' Message-ID: 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 wrote: > > 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. > 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.