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

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.
Previous: Tian YuchenNext: Christian Couder
Message 7 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.