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

Re: [PATCH] environment: use 'repo->initialized' for repo_protect_hfs() and repo_protect_ntfs()

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 20, 2026, 15:18 UTC
Message-ID
<xmqqpl1lfdg6.fsf@gitster.g>
In-Reply-To
<20260620140957.667820-1-cat@malon.dev>
Tian Yuchen <cat@malon.dev> writes:
> 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 ignore_case and trust_executable_bit, check the
> repo->initialized bit instead of the repo->gitdir member.
OK.
> Base commit: 43192e7977f5f05138abcdb3212a3f87ab513bef

This line does not belong here. Besides, you do not build directly on top of 'next', ever.

Show 8 quoted lines
> Mentored-by: Christian Couder <christian.couder@gmail.com>
> Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
> Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
> Signed-off-by: Tian Yuchen <cat@malon.dev>
> ---
>  environment.c | 4 ++--
>  environment.h | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)

I'll queue the change directly on top of ty/move-protect-hfs-ntfs topic, which will be merged to 'next'.

Thanks.
Show 36 quoted lines
> diff --git a/environment.c b/environment.c
> index 6ee11e9fc8..8f0c1c4f25 100644
> --- a/environment.c
> +++ b/environment.c
> @@ -130,14 +130,14 @@ int is_bare_repository(struct repository *repo)
>  
>  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 a/environment.h b/environment.h
> index d188955f5b..8aaedcfea3 100644
> --- a/environment.h
> +++ b/environment.h
> @@ -137,8 +137,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);
Previous: Tian Yuchen
Message 7 of 7 in “environment: move protect_hfs and protect_ntfs into repo_config_values”
  1. 0/1 environment: move protect_hfs and protect_ntfs into repo_config_valuesTian Yuchen, Jun 19, 2026
  2. 1/1 environment: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values'Tian Yuchen, Jun 19, 2026
  3. Junio C HamanoJun 19, 2026
  4. Junio C HamanoJun 19, 2026
  5. Tian YuchenJun 20, 2026
  6. environment: use 'repo->initialized' for repo_protect_hfs() and repo_protect_ntfs()Tian Yuchen, Jun 20, 2026
  7. Junio C HamanoJun 20, 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.