From: Junio C Hamano Date: Fri, 19 Jun 2026 17:14:43 GMT Subject: Re: [PATCH v4 0/1] environment: move protect_hfs and protect_ntfs into repo_config_values Message-ID: In-Reply-To: <20260619163823.652091-1-cat@malon.dev> Tian Yuchen writes: > This series continues the ongoing libification effort by moving the > global filesystem variables, 'protect_hfs' and 'protect_ntfs', into > 'struct repo_config_values'. > ... > Change since V3: > > - In repo_protect_hfs() and repo_protect_ntfs(), change repo->gitdir to > using (repo && repo->initialized). While I think that it is a good change for consistency with other two topics, the hfs/ntfs topic is already in 'next', so it needs to be handled differently. Namely, a topic in 'next' should not be replaced, but be improved by additional patches on top. In this particular case case, I think it would be good to have "to match how we refrain from calling repo_config_values() on an uninitialized instance of a repository object in other two topics that deal with X bit and Y bit, check the repo->initialized bit instead of the repo->gitdir member" or something like that in the log message to explain why we are making the change, perhaps. The patch text may look like this. environment.c | 4 ++-- environment.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git c/environment.c w/environment.c index 683fe1b4d3..f34f6fc750 100644 --- c/environment.c +++ w/environment.c @@ -142,14 +142,14 @@ int is_bare_repository(void) int repo_protect_ntfs(struct repository *repo) { - return repo->gitdir ? + return (repo && repo->initialized) ? repo_config_values(repo)->protect_ntfs : PROTECT_NTFS_DEFAULT; } int repo_protect_hfs(struct repository *repo) { - return repo->gitdir ? + return (repo && repo->initialized) ? repo_config_values(repo)->protect_hfs : PROTECT_HFS_DEFAULT; } diff --git c/environment.h w/environment.h index fdd9775900..b1ae4a70de 100644 --- c/environment.h +++ w/environment.h @@ -127,8 +127,8 @@ int git_default_core_config(const char *var, const char *value, /* * 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. + * They check `repo->initialized` to prevent calling `repo_config_values()` + * before the repository setup is fully complete or in non-git environments. */ int repo_protect_hfs(struct repository *repo); int repo_protect_ntfs(struct repository *repo);