From: Junio C Hamano Date: Wed, 10 Jun 2026 16:41:52 GMT Subject: Re: [PATCH v2 1/1] environment.c: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values' Message-ID: In-Reply-To: <20260610124353.149874-2-cat@malon.dev> Tian Yuchen 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? Thanks.