Re: [PATCH v2 1/1] environment.c: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values'
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 10, 2026, 16:41 UTC
- Message-ID
- <xmqqse6uwdnz.fsf@gitster.g>
- In-Reply-To
- <20260610124353.149874-2-cat@malon.dev>
Tian Yuchen <cat@malon.dev> writes:
Show 25 quoted lines
> +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.