environment: move ignore_case into repo_config_values
The 'core.ignorecase' configuration which is stored as the global variable 'ignore_case' acts as a core filesystem capability flag. Move this global variable into 'struct repo_config_values' to tie it to the specific repository instance it was read from. This reduces global state and aligns with the ongoing libification effort. To ensure code readability, the getter function 'repo_ignore_case()' is introduced. 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tian Yuchen committed
Jun 19, 2026 at 23:51 UTC
5abac96b4be55831c9aa5135ded30a907f76018c
2 files changed
+16
environment.c
+8
@@ -142,6 +142,13 @@ int is_bare_repository(void)
142
return is_bare_repository_cfg && !repo_get_work_tree(the_repository);
143
}
144
145
+int repo_ignore_case(struct repository *repo)
146
+{
147
+ return (repo && repo->initialized) ?
148
+ repo_config_values(repo)->ignore_case :
149
+ 0;
150
+}
151
+
152
int have_git_dir(void)
153
{
154
return startup_info->have_repository
@@ -720,5 +727,6 @@ void repo_config_values_init(struct repo_config_values *cfg)
727
{
728
cfg->attributes_file = NULL;
729
cfg->apply_sparse_checkout = 0;
730
+ cfg->ignore_case = 0;
731
cfg->branch_track = BRANCH_TRACK_REMOTE;
732
}
environment.h
+8
@@ -91,6 +91,7 @@ struct repo_config_values {
91
/* section "core" config values */
92
char *attributes_file;
93
int apply_sparse_checkout;
94
+ int ignore_case;
95
96
/* section "branch" config values */
97
enum branch_track branch_track;
@@ -123,6 +124,13 @@ int git_default_config(const char *, const char *,
124
int git_default_core_config(const char *var, const char *value,
125
const struct config_context *ctx, void *cb);
126
127
+/*
128
+ * Getter for the `ignore_case` field of `struct repo_config_values`.
129
+ * It checks `repo->initialized` to prevent calling repo_config_values()`
130
+ * before the repository setup is fully complete or in non-git environments.
131
+ */
132
+int repo_ignore_case(struct repository *repo);
133
+
134
void repo_config_values_init(struct repo_config_values *cfg);
135
136
/*