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

Re: [PATCH v4 0/1] environment: move protect_hfs and protect_ntfs into repo_config_values

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 19, 2026, 17:14 UTC
Message-ID
<xmqqo6h6jvuk.fsf@gitster.g>
In-Reply-To
<20260619163823.652091-1-cat@malon.dev>
Tian Yuchen <cat@malon.dev> writes:
Show 8 quoted lines
> 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);
Previous: Tian YuchenNext: Junio C Hamano
Message 3 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.