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

[PATCH v1 0/1] environment: move protect_hfs and protect_ntfs

From
Tian Yuchen <cat@malon.dev>
Date
Jun 6, 2026, 14:34 UTC
Message-ID
<20260606143412.15443-2-cat@malon.dev>
In-Reply-To
<20260606143412.15443-1-cat@malon.dev>
Hi everyone,

This series continues the ongoing libification effort by moving the global **filesystem** variables, protect_hfs and protect_ntfs, into struct repo_config_values.

Place them within the **per-repository** configuration structure aligns with our goal of removing global states.

RFC Questions:
1. Should we keep PROTECT_HFS_DEFAULT and PROTECT_NTFS_DEFAULT
in repo_config_values_init()?
	void repo_config_values_init(struct repo_config_values *cfg)
		{
			cfg->attributes_file = NULL;
			cfg->apply_sparse_checkout = 0;
			cfg->protect_hfs = PROTECT_HFS_DEFAULT;
			cfg->protect_ntfs = PROTECT_NTFS_DEFAULT;
			cfg->branch_track = BRANCH_TRACK_REMOTE;
		}
Or is it better if they are used anywhere other than in environment.c?
If so... 
2. Is it worth introducing a Macro or Getter for safe access?
	((the_repository->gitdir ? repo_config_values(the_repository)->protect_hfs : 0))

The current approach looks verbose and lacks readability, and hard-coded 0 and 1 are used as fallback values. I wonder if a macro or a getter could be introduced, for example...

	#define SAFE_PROTECT_HFS(repo) \
		(((repo) && (repo)->gitdir && (repo) == the_repository) ? \ 
		repo_config_values(repo)->protect_hfs : PROTECT_HFS_DEFAULT)

...to improve the coding style a bit. Although I am aware that introducing new macros is generally frowned upon, I would still like to know which parts this might make difficult to maintain.

3. Note that Derrick attempted to use get_int_config_global to wrap
this kind of Filesystem Level global variables. This approach bypassed
struct repository, did not actually eliminate global state, and the
reviewer politely rejected it. Nevertheless, I am still curious as
to whether this approach might still be inspiring today.
https://lore.kernel.org/git/a42dd9397d07b2dc4a0d7e75bfe1af2e46cad262.1685716420.git.gitgitgadget@gmail.com/
Thanks!
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>
Tian Yuchen (1):
  environment.c: move 'protect_hfs' and 'protect_ntfs' into
    'repo_config_values'
 compat/mingw.c             |  2 +-
 environment.c              |  8 ++++----
 environment.h              |  4 ++--
 read-cache.c               |  7 ++++---
 t/helper/test-path-utils.c | 26 ++++++++++++++++----------
 5 files changed, 27 insertions(+), 20 deletions(-)
-- 
2.43.0
Previous: Tian YuchenNext: Christian Couder
Message 2 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.