]> git.ipfire.org Git - thirdparty/git.git/commitdiff
environment: move ignore_case into repo_config_values
authorTian Yuchen <cat@malon.dev>
Fri, 19 Jun 2026 15:51:51 +0000 (23:51 +0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Jun 2026 17:04:56 +0000 (10:04 -0700)
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>
environment.c
environment.h

index fc3ed8bb1c7a66ae9be342c04700478a9af7f19d..bfa3cb3045fe74600ba18c395f3e511ba5f2b2e1 100644 (file)
@@ -142,6 +142,13 @@ int is_bare_repository(void)
        return is_bare_repository_cfg && !repo_get_work_tree(the_repository);
 }
 
+int repo_ignore_case(struct repository *repo)
+{
+       return (repo && repo->initialized) ?
+               repo_config_values(repo)->ignore_case :
+               0;
+}
+
 int have_git_dir(void)
 {
        return startup_info->have_repository
@@ -720,5 +727,6 @@ void repo_config_values_init(struct repo_config_values *cfg)
 {
        cfg->attributes_file = NULL;
        cfg->apply_sparse_checkout = 0;
+       cfg->ignore_case = 0;
        cfg->branch_track = BRANCH_TRACK_REMOTE;
 }
index 9eb97b3869c9b1bf9624042dc9435e585aaf11af..39a8bf0b49849dd861c841c4ac907f1ba4e16c11 100644 (file)
@@ -91,6 +91,7 @@ struct repo_config_values {
        /* section "core" config values */
        char *attributes_file;
        int apply_sparse_checkout;
+       int ignore_case;
 
        /* section "branch" config values */
        enum branch_track branch_track;
@@ -123,6 +124,13 @@ 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);
 
+/*
+ * Getter for the `ignore_case` field of `struct repo_config_values`.
+ * It checks `repo->initialized` to prevent calling repo_config_values()`
+ * before the repository setup is fully complete or in non-git environments.
+ */
+int repo_ignore_case(struct repository *repo);
+
 void repo_config_values_init(struct repo_config_values *cfg);
 
 /*