environment: move ignore_case into repo_config_values
cover environment: move ignore_case into repo_config_values
The 'core.ignorecase' configuration, stored as the global variable 'ignore_case', acts as a core filesystem capability flag.
This series continues the ongoing libification effort by moving this global variable into struct 'repo_config_values', tying it to the specific repository instance it was read from. This allows us to encapsulate the configuration without altering its eager-parsing behavior.
The getter function 'repo_get_ignore_case()' is introduced so that we can safely retrieve the configuration value whilst maintaining the correct fallback logic.
RFC Questions:
environment.h --- Is the fallback logic for repo_get_ignore_case() correct? I am unsure whether gitdir should be used here, since it might not be ready when we access it in the early stage of initialization (e.g. git init / git clone).
dir.c --- Performance overhead?
compat/win32/path-utils.c --- Is it appropriate to include the repository.h header file?
Related materials:
[1] In this patch to migrate protect_hfs and protect_ntfs, the approach of introducing getters has been endorsed.
[2] Derrick Stolee's previous attempt. The reasons for the failure are also mentioned in [1].
Thanks!
[1] https://lore.kernel.org/git/[email protected]/
[2] https://lore.kernel.org/git/2b4198c09cb6c04c60608d19072d419503dfe5df.1685716421.git.gitgitgadget@gmail.com/
Tian Yuchen (2):
environment: move ignore_case into repo_config_values
config: use repo_get_ignore_case() to access core.ignorecase
apply.c | 2 +- builtin/fetch.c | 2 +- builtin/mv.c | 2 +- compat/win32/path-utils.c | 3 ++- dir.c | 18 +++++++++--------- environment.c | 11 +++++++++-- environment.h | 9 ++++++++- fsmonitor.c | 2 +- name-hash.c | 6 +++--- read-cache.c | 6 +++--- refs/files-backend.c | 4 ++-- submodule.c | 2 +- t/helper/test-lazy-init-name-hash.c | 2 +- unpack-trees.c | 2 +- 14 files changed, 43 insertions(+), 28 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 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.
Note that the newly introduced getter, 'repo_get_ignore_case()', intentionally avoids checking 'repo->gitdir'. This could safely accommodates early dynamic probing of the filesystem during 'git init' or clone operations, where the 'gitdir' might not be fully initialized but the filesystem capability must be recorded.
--- environment.c | 8 ++++++++ environment.h | 8 ++++++++ 2 files changed, 16 insertions(+)
environment.c +8 -0
@@ -142,6 +142,13 @@ int is_bare_repository(void)return is_bare_repository_cfg && !repo_get_work_tree (the_repository); } +int repo_get_ignore_case (struct repository *repo) +{ +if (repo) +return repo_config_values (repo)->ignore_case; +return 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 ; }
environment.h +8 -0
@@ -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 intentionally avoids checking `repo->gitdir` to allow early dynamic +* probing during `git init` or clone. +*/ +int repo_get_ignore_case (struct repository *repo); +void repo_config_values_init (struct repo_config_values *cfg);/*
Signature · 1 line
2.43.0
PATCH 2/2 config: use repo_get_ignore_case() to access core.ignorecase
In reply to Tian YuchenReplace the accesses to the global 'ignore_case' variable with calls to 'repo_get_ignore_case(the_repository)'. This step eliminates the 'ignore_case' global state.
Note on compat/win32/path-utils.c:
To eliminate the global state, several helper functions (e.g. 'win32_fspathncmp()') now read from 'repo_get_ignore_case(the_repository)'. While this introduces dependency on 'repository.h' into the 'compat/', it avoids massive refactoring of the signatures across the codebase.
--- apply.c | 2 +- builtin/fetch.c | 2 +- builtin/mv.c | 2 +- compat/win32/path-utils.c | 3 ++- dir.c | 18 +++++++++--------- environment.c | 3 +-- environment.h | 1 - fsmonitor.c | 2 +- name-hash.c | 6 +++--- read-cache.c | 6 +++--- refs/files-backend.c | 4 ++-- submodule.c | 2 +- t/helper/test-lazy-init-name-hash.c | 2 +- unpack-trees.c | 2 +- 14 files changed, 27 insertions(+), 28 deletions(-)
apply.c +1 -1
@@ -4008,7 +4008,7 @@ static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *nastruct cache_entry *ce; ce =index_file_exists (state->repo->index, name->buf, - name->len, ignore_case); + name->len,repo_get_ignore_case (the_repository));if (ce &&S_ISLNK (ce->ce_mode))return 1 ; }else {
builtin/fetch.c +1 -1
@@ -1819,7 +1819,7 @@ static void ref_transaction_rejection_handler(const char *refname, {struct ref_rejection_data *data = cb_data; -if (err ==REF_TRANSACTION_ERROR_CASE_CONFLICT && ignore_case && +if (err ==REF_TRANSACTION_ERROR_CASE_CONFLICT &&repo_get_ignore_case (the_repository) && !data->case_sensitive_msg_shown) { error(_("You're on a case-insensitive filesystem, and the remote you are\n" "trying to fetch from has references that only differ in casing. It\n"
builtin/mv.c +1 -1
@@ -419,7 +419,7 @@ int cmd_mv(int argc, goto act_on_entry; }if (lstat (dst, &st) ==0 && - (!ignore_case ||strcasecmp (src, dst))) { + (!repo_get_ignore_case (the_repository) ||strcasecmp (src, dst))) { bad =_ ("destination exists" );if (force) {/*
compat/win32/path-utils.c +2 -1
@@ -2,6 +2,7 @@#include "../../git-compat-util.h" #include "../../environment.h" +#include "../../repository.h" int win32_has_dos_drive_prefix (const char *path) {
@@ -75,7 +76,7 @@ int win32_fspathncmp(const char *a, const char *b, size_t count) }else if (is_dir_sep (*b))return +1 ; - diff = ignore_case ? + diff =repo_get_ignore_case (the_repository) ? (unsigned char )tolower (*a) - (int )(unsigned char )tolower (*b) : (unsigned char )*a - (int )(unsigned char )*b;if (diff)
dir.c +9 -9
@@ -126,7 +126,7 @@ int count_slashes(const char *s)int git_fspathcmp (const char *a,const char *b) { -return ignore_case ?strcasecmp (a, b) :strcmp (a, b); +return repo_get_ignore_case (the_repository) ?strcasecmp (a, b) :strcmp (a, b); }int fspatheq (const char *a,const char *b)
@@ -136,7 +136,7 @@ int fspatheq(const char *a, const char *b)int git_fspathncmp (const char *a,const char *b,size_t count) { -return ignore_case ?strncasecmp (a, b, count) :strncmp (a, b, count); +return repo_get_ignore_case (the_repository) ?strncasecmp (a, b, count) :strncmp (a, b, count); }int paths_collide (const char *a,const char *b)
@@ -153,7 +153,7 @@ int paths_collide(const char *a, const char *b)unsigned int fspathhash (const char *str) { -return ignore_case ?strihash (str) :strhash (str); +return repo_get_ignore_case (the_repository) ?strihash (str) :strhash (str); } int git_fnmatch(const struct pathspec_item *item,
@@ -202,7 +202,7 @@ static int fnmatch_icase_mem(const char *pattern, int patternlen, use_str = str_buf.buf; } -if (ignore_case) +if (repo_get_ignore_case (the_repository)) flags |=WM_CASEFOLD ; match_status =wildmatch (use_pat, use_str, flags);
@@ -1851,7 +1851,7 @@ static struct dir_entry *dir_add_name(struct dir_struct *dir,struct index_state *istate, const char *pathname, int len) { - if (index_file_exists(istate, pathname, len, ignore_case)) + if (index_file_exists(istate, pathname, len, repo_get_ignore_case(the_repository))) return NULL;ALLOC_GROW (dir->entries, dir->nr+1 , dir->internal.alloc);
@@ -1888,7 +1888,7 @@ static enum exist_status directory_exists_in_index_icase(struct index_state *istif (index_dir_exists (istate, dirname, len))return index_directory; - ce =index_file_exists (istate, dirname, len, ignore_case); + ce =index_file_exists (istate, dirname, len,repo_get_ignore_case (the_repository));if (ce &&S_ISGITLINK (ce->ce_mode))return index_gitdir;
@@ -1907,7 +1907,7 @@ static enum exist_status directory_exists_in_index(struct index_state *istate, {int pos; -if (ignore_case) +if (repo_get_ignore_case (the_repository))return directory_exists_in_index_icase (istate, dirname, len); pos =index_name_pos (istate, dirname, len);
@@ -2447,7 +2447,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,/* Always exclude indexed files */ has_path_in_index = !!index_file_exists (istate, path->buf, path->len, - ignore_case); +repo_get_ignore_case (the_repository));if (dtype !=DT_DIR && has_path_in_index)return path_none;
@@ -3201,7 +3201,7 @@ static int cmp_icase(char a, char b) {if (a == b)return 0 ; -if (ignore_case) +if (repo_get_ignore_case (the_repository))return toupper (a) -toupper (b);return a - b; }
environment.c +1 -2
@@ -46,7 +46,6 @@ int trust_ctime = 1;int check_stat =1 ;int has_symlinks =1 ;int minimum_abbrev =4 , default_abbrev =-1 ; -int ignore_case;int assume_unchanged;int is_bare_repository_cfg =-1 ;/* unspecified */ int warn_on_object_refname_ambiguity =1 ;
@@ -342,7 +341,7 @@ int git_default_core_config(const char *var, const char *value, }if (!strcmp (var,"core.ignorecase" )) { - ignore_case =git_config_bool (var, value); + cfg->ignore_case =git_config_bool (var, value);return 0 ; }
environment.h +0 -1
@@ -171,7 +171,6 @@ extern int trust_ctime;extern int check_stat;extern int has_symlinks;extern int minimum_abbrev, default_abbrev; -extern int ignore_case;extern int assume_unchanged;extern int warn_on_object_refname_ambiguity;extern char *apply_default_whitespace;
fsmonitor.c +1 -1
@@ -453,7 +453,7 @@ static void fsmonitor_refresh_callback(struct index_state *istate, char *name)* case-insensitive file system, try again using the name-hash * and dir-name-hash. */ -if (!nr_in_cone && ignore_case) { +if (!nr_in_cone &&repo_get_ignore_case (the_repository)) { nr_in_cone =handle_using_name_hash_icase (istate, name);if (!nr_in_cone) nr_in_cone = handle_using_dir_name_hash_icase(
name-hash.c +3 -3
@@ -126,7 +126,7 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)hashmap_add (&istate->name_hash, &ce->ent); } -if (ignore_case) +if (repo_get_ignore_case (the_repository))add_dir_entry (istate, ce); }
@@ -207,7 +207,7 @@ static int lookup_lazy_params(struct index_state *istate)* code to build the "istate->name_hash". We don't * need the complexity here. */ -if (!ignore_case) +if (!repo_get_ignore_case (the_repository))return 0 ; nr_cpus =online_cpus ();
@@ -651,7 +651,7 @@ void remove_name_hash(struct index_state *istate, struct cache_entry *ce) ce->ce_flags &= ~CE_HASHED ;hashmap_remove (&istate->name_hash, &ce->ent, ce); -if (ignore_case) +if (repo_get_ignore_case (the_repository))remove_dir_entry (istate, ce); }
read-cache.c +3 -3
@@ -760,12 +760,12 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,* case of the file being added to the repository matches (is folded into) the existing * entry's directory case. */ -if (ignore_case) { +if (repo_get_ignore_case (the_repository)) {adjust_dirname_case (istate, ce->name); }if (!(flags &ADD_CACHE_RENORMALIZE )) { alias =index_file_exists (istate, ce->name, -ce_namelen (ce), ignore_case); +ce_namelen (ce),repo_get_ignore_case (the_repository));if (alias && !ce_stage (alias) && !ie_match_stat (istate, alias, st, ce_option)) {
@@ -786,7 +786,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, }else set_object_name_for_intent_to_add_entry (ce); -if (ignore_case && alias &&different_name (ce, alias)) +if (repo_get_ignore_case (the_repository) && alias &&different_name (ce, alias)) ce =create_alias_ce (istate, ce, alias); ce->ce_flags |=CE_ADDED ;
refs/files-backend.c +2 -2
@@ -806,7 +806,7 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs, }else {unable_to_lock_message (ref_file.buf, myerr, err);if (myerr ==EEXIST ) { -if (ignore_case && +if (repo_get_ignore_case (the_repository) &&transaction_has_case_conflicting_update (transaction, update)) {/* * In case-insensitive filesystems, ensure that conflicts within a
@@ -920,7 +920,7 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs,* conflicts between 'foo' and 'Foo/bar'. So let's lowercase * the refname. */ -if (ignore_case) { +if (repo_get_ignore_case (the_repository)) {struct strbuf lower =STRBUF_INIT ;strbuf_addstr (&lower, refname);
submodule.c +1 -1
@@ -2389,7 +2389,7 @@ static int validate_submodule_encoded_git_dir(char *git_dir, const char *submodu/* Prevent conflicts on case-folding filesystems */ repo_config_get_bool (the_repository,"core.ignorecase" , &config_ignorecase); -if (ignore_case || config_ignorecase) { +if (repo_get_ignore_case (the_repository) || config_ignorecase) {bool suffixes_match = !strcmp (last_submodule_name, submodule_name);return check_casefolding_conflict (git_dir, submodule_name, suffixes_match);
t/helper/test-lazy-init-name-hash.c +1 -1
@@ -218,7 +218,7 @@ int cmd__lazy_init_name_hash(int argc, const char **argv)/* * istate->dir_hash is only created when ignore_case is set. */ - ignore_case =1 ; +repo_config_values (the_repository)->ignore_case =1 ;if (dump) {if (perf || analyze >0 )
unpack-trees.c +1 -1
@@ -2428,7 +2428,7 @@ static int check_ok_to_remove(const char *name, int len, int dtype,* * Ignore that lstat() if it matches. */ -if (ignore_case &&icase_exists (o, name, len, st)) +if (repo_get_ignore_case (the_repository) &&icase_exists (o, name, len, st))return 0 ; if (o->internal.dir &&
Signature · 1 line
2.43.0
Quoted 5 lines · Tian Yuchen
Note that the newly introduced getter, '
repo_get_ignore_case()', intentionally avoids checking 'repo->gitdir'. This could safely accommodates early dynamic probing of the filesystem during 'git init' or clone operations, where the 'gitdir' might not be fully initialized but the filesystem capability must be recorded.
Why "could"? It either "safely accommodates" or it doesn't.
I do not quite understand the logic behind this part. Why is it OK to punt until .gitdir is ready for trust-executable-bit, like it is done in f951ed98 (environment: move trust_executable_bit into repo_config_values, 2026-06-13)
environment.c +7 -0
@@ -142,6 +141,13 @@ int is_bare_repository(void)return is_bare_repository_cfg && !repo_get_work_tree (the_repository); } +int repo_trust_executable_bit (struct repository *repo) +{ +return repo->gitdir? +repo_config_values (repo)->trust_executable_bit : +1 ; +} +
or hfs/ntfs in 71386c21 (environment: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values', 2026-06-10)
environment.c +14 -0
@@ -142,6 +140,20 @@ int is_bare_repository(void)return is_bare_repository_cfg && !repo_get_work_tree (the_repository); } +int repo_protect_ntfs (struct repository *repo) +{ +return repo->gitdir ? +repo_config_values (repo)->protect_ntfs : +PROTECT_NTFS_DEFAULT ; +} + +int repo_protect_hfs (struct repository *repo) +{ +return repo->gitdir ? +repo_config_values (repo)->protect_hfs : +PROTECT_HFS_DEFAULT ; +} +int have_git_dir (void ) {return startup_info->have_repository
but not for this bit?
Review
Quoted 6 lines
(quoted diff) +6
-0+int repo_get_ignore_case(struct repository *repo) +{ + if (repo) + return repo_config_values(repo)->ignore_case; + return 0; +}
What makes ignore-case so special? Doesn't the same logic apply to the other three bits?
Or use a more direct
if (repo && repo->initialized) ...;
for all three, as repo_config_values(repo) barfs when repo is not initialized?
I dunno.
Quoted 10 lines · Junio C Hamano
Quoted 5 lines · Tian Yuchen
Note that the newly introduced getter, '
repo_get_ignore_case()', intentionally avoids checking 'repo->gitdir'. This could safely accommodates early dynamic probing of the filesystem during 'git init' or clone operations, where the 'gitdir' might not be fully initialized but the filesystem capability must be recorded.Why "could"? It either "safely accommodates" or it doesn't.
Okay, will change in the next reroll.
Quoted 50 lines
I do not quite understand the logic behind this part. Why is it OK to punt until .gitdir is ready for trust-executable-bit, like it is done in
f951ed98(environment: movetrust_executable_bitintorepo_config_values, 2026-06-13)environment.c +7
-0@@ -142,6 +141,13 @@ int is_bare_repository(void)return is_bare_repository_cfg && !repo_get_work_tree (the_repository); } +int repo_trust_executable_bit (struct repository *repo) +{ +return repo->gitdir? +repo_config_values (repo)->trust_executable_bit : +1 ; +} +or hfs/ntfs in
71386c21(environment: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values', 2026-06-10)environment.c +14
-0@@ -142,6 +140,20 @@ int is_bare_repository(void)return is_bare_repository_cfg && !repo_get_work_tree (the_repository); } +int repo_protect_ntfs (struct repository *repo) +{ +return repo->gitdir ? +repo_config_values (repo)->protect_ntfs : +PROTECT_NTFS_DEFAULT ; +} + +int repo_protect_hfs (struct repository *repo) +{ +return repo->gitdir ? +repo_config_values (repo)->protect_hfs : +PROTECT_HFS_DEFAULT ; +} +int have_git_dir (void ) {return startup_info->have_repository
Quoted 1 line
but not for this bit?
You're right, I made a mistake.
Earlier, when I was testing using 'repo->gitdir', the CI tests failed, and I thought it was because the test script was forcing initial values too early. I just realized the error was somewhere else. I'll fix it.
Quoted 13 lines
Review
Quoted 7 lines
(quoted diff) +6
-0+int repo_get_ignore_case(struct repository *repo) +{ + if (repo) + return repo_config_values(repo)->ignore_case; + return 0; +}What makes ignore-case so special? Doesn't the same logic apply to the other three bits?
Or use a more direct
Quoted 7 lines
if (repo && repo->initialized) ...;for all three, as
repo_config_values(repo)barfs when repo is not initialized?I dunno.
That makes some sense. The reasoning behind using 'repo->gitdir' is that "as long as I know where .git is, I assume the repository has been initialized," which may indeed be less precise than 'repo->initialized'.
Btw, I think it's better to change the getter's name from 'repo_get_ignore_case()' to 'repo_ignore_case()'. This way, it will be consistent with the previous flags.
Thanks, yuchen
v2 cover environment: move ignore_case into repo_config_values
In reply to Tian YuchenThe 'core.ignorecase' configuration, stored as the global variable 'ignore_case', acts as a core filesystem capability flag.
This series continues the ongoing libification effort by moving this global variable into 'struct repo_config_values', tying it to the specific repository instance it was read from. This allows us to encapsulate the configuration without altering its eager-parsing behavior.
The getter function 'repo_ignore_case()' is introduced so that we can safely retrieve the configuration value whilst maintaining the correct fallback logic.
RFC Questions:
dir.c --- Performance overhead?
compat/win32/path-utils.c --- Is it appropriate to include the repository.h header file?
Related materials:
[1] In this patch to migrate protect_hfs and protect_ntfs, the approach
of introducing getters has been endorsed.
[2] Derrick Stolee's previous attempt. The reasons for the failure are
also mentioned in [1].
Changes since V1:
- s/repo_get_ignore_case()/repo_ignore_case()
- Use repo->initialized instead of repo->gitdir
Thanks!
[1] https://lore.kernel.org/git/[email protected]/
[2] https://lore.kernel.org/git/2b4198c09cb6c04c60608d19072d419503dfe5df.1685716421.git.gitgitgadget@gmail.com/
Tian Yuchen (2):
environment: move ignore_case into repo_config_values
config: use repo_ignore_case() to access core.ignorecase
apply.c | 2 +- builtin/fetch.c | 2 +- builtin/mv.c | 2 +- compat/win32/path-utils.c | 3 ++- dir.c | 18 +++++++++--------- environment.c | 11 +++++++++-- environment.h | 9 ++++++++- fsmonitor.c | 2 +- name-hash.c | 6 +++--- read-cache.c | 6 +++--- refs/files-backend.c | 4 ++-- submodule.c | 2 +- t/helper/test-lazy-init-name-hash.c | 2 +- unpack-trees.c | 2 +- 14 files changed, 43 insertions(+), 28 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 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.
--- environment.c | 8 ++++++++ environment.h | 8 ++++++++ 2 files changed, 16 insertions(+)
environment.c +8 -0
@@ -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 ; }
environment.h +8 -0
@@ -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);/*
Signature · 1 line
2.43.0
PATCH v2 2/2 config: use repo_ignore_case() to access core.ignorecase
In reply to Tian YuchenReplace the accesses to the global 'ignore_case' variable with calls to 'repo_ignore_case(the_repository)'. This step eliminates the 'ignore_case' global state.
Note on compat/win32/path-utils.c:
To eliminate the global state, several helper functions (e.g. 'win32_fspathncmp()') now read from 'repo_ignore_case(the_repository)'. While this introduces dependency on 'repository.h' into the 'compat/', it avoids massive refactoring of the signatures across the codebase.
--- apply.c | 2 +- builtin/fetch.c | 2 +- builtin/mv.c | 2 +- compat/win32/path-utils.c | 3 ++- dir.c | 18 +++++++++--------- environment.c | 3 +-- environment.h | 1 - fsmonitor.c | 2 +- name-hash.c | 6 +++--- read-cache.c | 6 +++--- refs/files-backend.c | 4 ++-- submodule.c | 2 +- t/helper/test-lazy-init-name-hash.c | 2 +- unpack-trees.c | 2 +- 14 files changed, 27 insertions(+), 28 deletions(-)
apply.c +1 -1
@@ -4008,7 +4008,7 @@ static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *nastruct cache_entry *ce; ce =index_file_exists (state->repo->index, name->buf, - name->len, ignore_case); + name->len,repo_ignore_case (the_repository));if (ce &&S_ISLNK (ce->ce_mode))return 1 ; }else {
builtin/fetch.c +1 -1
@@ -1819,7 +1819,7 @@ static void ref_transaction_rejection_handler(const char *refname, {struct ref_rejection_data *data = cb_data; -if (err ==REF_TRANSACTION_ERROR_CASE_CONFLICT && ignore_case && +if (err ==REF_TRANSACTION_ERROR_CASE_CONFLICT &&repo_ignore_case (the_repository) && !data->case_sensitive_msg_shown) { error(_("You're on a case-insensitive filesystem, and the remote you are\n" "trying to fetch from has references that only differ in casing. It\n"
builtin/mv.c +1 -1
@@ -419,7 +419,7 @@ int cmd_mv(int argc, goto act_on_entry; }if (lstat (dst, &st) ==0 && - (!ignore_case ||strcasecmp (src, dst))) { + (!repo_ignore_case (the_repository) ||strcasecmp (src, dst))) { bad =_ ("destination exists" );if (force) {/*
compat/win32/path-utils.c +2 -1
@@ -2,6 +2,7 @@#include "../../git-compat-util.h" #include "../../environment.h" +#include "../../repository.h" int win32_has_dos_drive_prefix (const char *path) {
@@ -75,7 +76,7 @@ int win32_fspathncmp(const char *a, const char *b, size_t count) }else if (is_dir_sep (*b))return +1 ; - diff = ignore_case ? + diff =repo_ignore_case (the_repository) ? (unsigned char )tolower (*a) - (int )(unsigned char )tolower (*b) : (unsigned char )*a - (int )(unsigned char )*b;if (diff)
dir.c +9 -9
@@ -126,7 +126,7 @@ int count_slashes(const char *s)int git_fspathcmp (const char *a,const char *b) { -return ignore_case ?strcasecmp (a, b) :strcmp (a, b); +return repo_ignore_case (the_repository) ?strcasecmp (a, b) :strcmp (a, b); }int fspatheq (const char *a,const char *b)
@@ -136,7 +136,7 @@ int fspatheq(const char *a, const char *b)int git_fspathncmp (const char *a,const char *b,size_t count) { -return ignore_case ?strncasecmp (a, b, count) :strncmp (a, b, count); +return repo_ignore_case (the_repository) ?strncasecmp (a, b, count) :strncmp (a, b, count); }int paths_collide (const char *a,const char *b)
@@ -153,7 +153,7 @@ int paths_collide(const char *a, const char *b)unsigned int fspathhash (const char *str) { -return ignore_case ?strihash (str) :strhash (str); +return repo_ignore_case (the_repository) ?strihash (str) :strhash (str); } int git_fnmatch(const struct pathspec_item *item,
@@ -202,7 +202,7 @@ static int fnmatch_icase_mem(const char *pattern, int patternlen, use_str = str_buf.buf; } -if (ignore_case) +if (repo_ignore_case (the_repository)) flags |=WM_CASEFOLD ; match_status =wildmatch (use_pat, use_str, flags);
@@ -1851,7 +1851,7 @@ static struct dir_entry *dir_add_name(struct dir_struct *dir,struct index_state *istate, const char *pathname, int len) { - if (index_file_exists(istate, pathname, len, ignore_case)) + if (index_file_exists(istate, pathname, len, repo_ignore_case(the_repository))) return NULL;ALLOC_GROW (dir->entries, dir->nr+1 , dir->internal.alloc);
@@ -1888,7 +1888,7 @@ static enum exist_status directory_exists_in_index_icase(struct index_state *istif (index_dir_exists (istate, dirname, len))return index_directory; - ce =index_file_exists (istate, dirname, len, ignore_case); + ce =index_file_exists (istate, dirname, len,repo_ignore_case (the_repository));if (ce &&S_ISGITLINK (ce->ce_mode))return index_gitdir;
@@ -1907,7 +1907,7 @@ static enum exist_status directory_exists_in_index(struct index_state *istate, {int pos; -if (ignore_case) +if (repo_ignore_case (the_repository))return directory_exists_in_index_icase (istate, dirname, len); pos =index_name_pos (istate, dirname, len);
@@ -2447,7 +2447,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,/* Always exclude indexed files */ has_path_in_index = !!index_file_exists (istate, path->buf, path->len, - ignore_case); +repo_ignore_case (the_repository));if (dtype !=DT_DIR && has_path_in_index)return path_none;
@@ -3201,7 +3201,7 @@ static int cmp_icase(char a, char b) {if (a == b)return 0 ; -if (ignore_case) +if (repo_ignore_case (the_repository))return toupper (a) -toupper (b);return a - b; }
environment.c +1 -2
@@ -46,7 +46,6 @@ int trust_ctime = 1;int check_stat =1 ;int has_symlinks =1 ;int minimum_abbrev =4 , default_abbrev =-1 ; -int ignore_case;int assume_unchanged;int is_bare_repository_cfg =-1 ;/* unspecified */ int warn_on_object_refname_ambiguity =1 ;
@@ -342,7 +341,7 @@ int git_default_core_config(const char *var, const char *value, }if (!strcmp (var,"core.ignorecase" )) { - ignore_case =git_config_bool (var, value); + cfg->ignore_case =git_config_bool (var, value);return 0 ; }
environment.h +0 -1
@@ -171,7 +171,6 @@ extern int trust_ctime;extern int check_stat;extern int has_symlinks;extern int minimum_abbrev, default_abbrev; -extern int ignore_case;extern int assume_unchanged;extern int warn_on_object_refname_ambiguity;extern char *apply_default_whitespace;
fsmonitor.c +1 -1
@@ -453,7 +453,7 @@ static void fsmonitor_refresh_callback(struct index_state *istate, char *name)* case-insensitive file system, try again using the name-hash * and dir-name-hash. */ -if (!nr_in_cone && ignore_case) { +if (!nr_in_cone &&repo_ignore_case (the_repository)) { nr_in_cone =handle_using_name_hash_icase (istate, name);if (!nr_in_cone) nr_in_cone = handle_using_dir_name_hash_icase(
name-hash.c +3 -3
@@ -126,7 +126,7 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)hashmap_add (&istate->name_hash, &ce->ent); } -if (ignore_case) +if (repo_ignore_case (the_repository))add_dir_entry (istate, ce); }
@@ -207,7 +207,7 @@ static int lookup_lazy_params(struct index_state *istate)* code to build the "istate->name_hash". We don't * need the complexity here. */ -if (!ignore_case) +if (!repo_ignore_case (the_repository))return 0 ; nr_cpus =online_cpus ();
@@ -651,7 +651,7 @@ void remove_name_hash(struct index_state *istate, struct cache_entry *ce) ce->ce_flags &= ~CE_HASHED ;hashmap_remove (&istate->name_hash, &ce->ent, ce); -if (ignore_case) +if (repo_ignore_case (the_repository))remove_dir_entry (istate, ce); }
read-cache.c +3 -3
@@ -760,12 +760,12 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,* case of the file being added to the repository matches (is folded into) the existing * entry's directory case. */ -if (ignore_case) { +if (repo_ignore_case (the_repository)) {adjust_dirname_case (istate, ce->name); }if (!(flags &ADD_CACHE_RENORMALIZE )) { alias =index_file_exists (istate, ce->name, -ce_namelen (ce), ignore_case); +ce_namelen (ce),repo_ignore_case (the_repository));if (alias && !ce_stage (alias) && !ie_match_stat (istate, alias, st, ce_option)) {
@@ -786,7 +786,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, }else set_object_name_for_intent_to_add_entry (ce); -if (ignore_case && alias &&different_name (ce, alias)) +if (repo_ignore_case (the_repository) && alias &&different_name (ce, alias)) ce =create_alias_ce (istate, ce, alias); ce->ce_flags |=CE_ADDED ;
refs/files-backend.c +2 -2
@@ -806,7 +806,7 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs, }else {unable_to_lock_message (ref_file.buf, myerr, err);if (myerr ==EEXIST ) { -if (ignore_case && +if (repo_ignore_case (the_repository) &&transaction_has_case_conflicting_update (transaction, update)) {/* * In case-insensitive filesystems, ensure that conflicts within a
@@ -920,7 +920,7 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs,* conflicts between 'foo' and 'Foo/bar'. So let's lowercase * the refname. */ -if (ignore_case) { +if (repo_ignore_case (the_repository)) {struct strbuf lower =STRBUF_INIT ;strbuf_addstr (&lower, refname);
submodule.c +1 -1
@@ -2389,7 +2389,7 @@ static int validate_submodule_encoded_git_dir(char *git_dir, const char *submodu/* Prevent conflicts on case-folding filesystems */ repo_config_get_bool (the_repository,"core.ignorecase" , &config_ignorecase); -if (ignore_case || config_ignorecase) { +if (repo_ignore_case (the_repository) || config_ignorecase) {bool suffixes_match = !strcmp (last_submodule_name, submodule_name);return check_casefolding_conflict (git_dir, submodule_name, suffixes_match);
t/helper/test-lazy-init-name-hash.c +1 -1
@@ -218,7 +218,7 @@ int cmd__lazy_init_name_hash(int argc, const char **argv)/* * istate->dir_hash is only created when ignore_case is set. */ - ignore_case =1 ; +repo_config_values (the_repository)->ignore_case =1 ;if (dump) {if (perf || analyze >0 )
unpack-trees.c +1 -1
@@ -2428,7 +2428,7 @@ static int check_ok_to_remove(const char *name, int len, int dtype,* * Ignore that lstat() if it matches. */ -if (ignore_case &&icase_exists (o, name, len, st)) +if (repo_ignore_case (the_repository) &&icase_exists (o, name, len, st))return 0 ; if (o->internal.dir &&
Signature · 1 line
2.43.0
Quoted 7 lines · Tian Yuchen
Related materials:
[1] In this patch to migrate
protect_hfsandprotect_ntfs, the approach
of introducing getters has been endorsed.[2] Derrick Stolee's previous attempt. The reasons for the failure are
also mentioned in [1].
[1] here refers to the starting message of the whole hfs/ntfs thing. Do you mean that people must read the entire thread to find out what the reasons for the failure was? For that matter, it is not clear, unless readers read the whole thread, where the approach of using getters was "endorsed", either.
Quoted 8 lines
[1] https://lore.kernel.org/git/[email protected]/
[2] https://lore.kernel.org/git/2b4198c09cb6c04c60608d19072d419503dfe5df.1685716421.git.gitgitgadget@gmail.com/Changes since V1:
- s/repo_get_ignore_case()/repo_ignore_case()
- Use
repo->initializedinstead ofrepo->gitdir
I do not think I have any objections to these changes from the previous iteration. There may be some other things in the new iteration but I'll have to go in and read the patches to find them out (if they exist).
Thanks.
v3 cover environment: move ignore_case into repo_config_values
In reply to Tian YuchenThis series continues the ongoing libification effort by moving this global variable into 'struct repo_config_values', tying it to the specific repository instance it was read from. This allows us to encapsulate the configuration without altering its eager-parsing behavior.
The getter function 'repo_ignore_case()' is introduced so that we can safely retrieve the configuration value whilst maintaining the correct fallback logic.
RFC Questions:
dir.c --- Performance overhead?
compat/win32/path-utils.c --- Is it appropriate to include the repository.h header file?
Related materials:
[1] The practice of introducing getters for filesystem flags to ensure safe access was previously introduced in this patch to migrate 'protect_hfs' and 'protect_ntfs'.
When migrating 'ignore_case', the same approach is strictly followed.
[2] Derrick Stolee's previous attempt. This patch series attempted to wrap this kind of filesystem-level variable using a lazy-loaded global accessor get_int_config_global().
However, as Glen Choo pointed out in his review of that series, it is strongly preferred to use plain fields in a repository-scoped struct over global lazy-loaders, provided those fields are properly initialized during the setup process.
Changes since V2:
- Revise the cover letter to clarify what the links lead to.
Thanks!
[1] https://lore.kernel.org/git/[email protected]/
[2] https://lore.kernel.org/git/2b4198c09cb6c04c60608d19072d419503dfe5df.1685716421.git.gitgitgadget@gmail.com/
Tian Yuchen (2):
environment: move ignore_case into repo_config_values
config: use repo_ignore_case() to access core.ignorecase
apply.c | 2 +- builtin/fetch.c | 2 +- builtin/mv.c | 2 +- compat/win32/path-utils.c | 3 ++- dir.c | 18 +++++++++--------- environment.c | 11 +++++++++-- environment.h | 9 ++++++++- fsmonitor.c | 2 +- name-hash.c | 6 +++--- read-cache.c | 6 +++--- refs/files-backend.c | 4 ++-- submodule.c | 2 +- t/helper/test-lazy-init-name-hash.c | 2 +- unpack-trees.c | 2 +- 14 files changed, 43 insertions(+), 28 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/2 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.
--- environment.c | 8 ++++++++ environment.h | 8 ++++++++ 2 files changed, 16 insertions(+)
environment.c +8 -0
@@ -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 ; }
environment.h +8 -0
@@ -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);/*
Signature · 1 line
2.43.0
PATCH v3 2/2 config: use repo_ignore_case() to access core.ignorecase
In reply to Tian YuchenReplace the accesses to the global 'ignore_case' variable with calls to 'repo_ignore_case(the_repository)'. This step eliminates the 'ignore_case' global state.
Note on compat/win32/path-utils.c:
To eliminate the global state, several helper functions (e.g. 'win32_fspathncmp()') now read from 'repo_ignore_case(the_repository)'. While this introduces dependency on 'repository.h' into the 'compat/', it avoids massive refactoring of the signatures across the codebase.
--- apply.c | 2 +- builtin/fetch.c | 2 +- builtin/mv.c | 2 +- compat/win32/path-utils.c | 3 ++- dir.c | 18 +++++++++--------- environment.c | 3 +-- environment.h | 1 - fsmonitor.c | 2 +- name-hash.c | 6 +++--- read-cache.c | 6 +++--- refs/files-backend.c | 4 ++-- submodule.c | 2 +- t/helper/test-lazy-init-name-hash.c | 2 +- unpack-trees.c | 2 +- 14 files changed, 27 insertions(+), 28 deletions(-)
apply.c +1 -1
@@ -4008,7 +4008,7 @@ static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *nastruct cache_entry *ce; ce =index_file_exists (state->repo->index, name->buf, - name->len, ignore_case); + name->len,repo_ignore_case (the_repository));if (ce &&S_ISLNK (ce->ce_mode))return 1 ; }else {
builtin/fetch.c +1 -1
@@ -1819,7 +1819,7 @@ static void ref_transaction_rejection_handler(const char *refname, {struct ref_rejection_data *data = cb_data; -if (err ==REF_TRANSACTION_ERROR_CASE_CONFLICT && ignore_case && +if (err ==REF_TRANSACTION_ERROR_CASE_CONFLICT &&repo_ignore_case (the_repository) && !data->case_sensitive_msg_shown) { error(_("You're on a case-insensitive filesystem, and the remote you are\n" "trying to fetch from has references that only differ in casing. It\n"
builtin/mv.c +1 -1
@@ -419,7 +419,7 @@ int cmd_mv(int argc, goto act_on_entry; }if (lstat (dst, &st) ==0 && - (!ignore_case ||strcasecmp (src, dst))) { + (!repo_ignore_case (the_repository) ||strcasecmp (src, dst))) { bad =_ ("destination exists" );if (force) {/*
compat/win32/path-utils.c +2 -1
@@ -2,6 +2,7 @@#include "../../git-compat-util.h" #include "../../environment.h" +#include "../../repository.h" int win32_has_dos_drive_prefix (const char *path) {
@@ -75,7 +76,7 @@ int win32_fspathncmp(const char *a, const char *b, size_t count) }else if (is_dir_sep (*b))return +1 ; - diff = ignore_case ? + diff =repo_ignore_case (the_repository) ? (unsigned char )tolower (*a) - (int )(unsigned char )tolower (*b) : (unsigned char )*a - (int )(unsigned char )*b;if (diff)
dir.c +9 -9
@@ -126,7 +126,7 @@ int count_slashes(const char *s)int git_fspathcmp (const char *a,const char *b) { -return ignore_case ?strcasecmp (a, b) :strcmp (a, b); +return repo_ignore_case (the_repository) ?strcasecmp (a, b) :strcmp (a, b); }int fspatheq (const char *a,const char *b)
@@ -136,7 +136,7 @@ int fspatheq(const char *a, const char *b)int git_fspathncmp (const char *a,const char *b,size_t count) { -return ignore_case ?strncasecmp (a, b, count) :strncmp (a, b, count); +return repo_ignore_case (the_repository) ?strncasecmp (a, b, count) :strncmp (a, b, count); }int paths_collide (const char *a,const char *b)
@@ -153,7 +153,7 @@ int paths_collide(const char *a, const char *b)unsigned int fspathhash (const char *str) { -return ignore_case ?strihash (str) :strhash (str); +return repo_ignore_case (the_repository) ?strihash (str) :strhash (str); } int git_fnmatch(const struct pathspec_item *item,
@@ -202,7 +202,7 @@ static int fnmatch_icase_mem(const char *pattern, int patternlen, use_str = str_buf.buf; } -if (ignore_case) +if (repo_ignore_case (the_repository)) flags |=WM_CASEFOLD ; match_status =wildmatch (use_pat, use_str, flags);
@@ -1851,7 +1851,7 @@ static struct dir_entry *dir_add_name(struct dir_struct *dir,struct index_state *istate, const char *pathname, int len) { - if (index_file_exists(istate, pathname, len, ignore_case)) + if (index_file_exists(istate, pathname, len, repo_ignore_case(the_repository))) return NULL;ALLOC_GROW (dir->entries, dir->nr+1 , dir->internal.alloc);
@@ -1888,7 +1888,7 @@ static enum exist_status directory_exists_in_index_icase(struct index_state *istif (index_dir_exists (istate, dirname, len))return index_directory; - ce =index_file_exists (istate, dirname, len, ignore_case); + ce =index_file_exists (istate, dirname, len,repo_ignore_case (the_repository));if (ce &&S_ISGITLINK (ce->ce_mode))return index_gitdir;
@@ -1907,7 +1907,7 @@ static enum exist_status directory_exists_in_index(struct index_state *istate, {int pos; -if (ignore_case) +if (repo_ignore_case (the_repository))return directory_exists_in_index_icase (istate, dirname, len); pos =index_name_pos (istate, dirname, len);
@@ -2447,7 +2447,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,/* Always exclude indexed files */ has_path_in_index = !!index_file_exists (istate, path->buf, path->len, - ignore_case); +repo_ignore_case (the_repository));if (dtype !=DT_DIR && has_path_in_index)return path_none;
@@ -3201,7 +3201,7 @@ static int cmp_icase(char a, char b) {if (a == b)return 0 ; -if (ignore_case) +if (repo_ignore_case (the_repository))return toupper (a) -toupper (b);return a - b; }
environment.c +1 -2
@@ -46,7 +46,6 @@ int trust_ctime = 1;int check_stat =1 ;int has_symlinks =1 ;int minimum_abbrev =4 , default_abbrev =-1 ; -int ignore_case;int assume_unchanged;int is_bare_repository_cfg =-1 ;/* unspecified */ int warn_on_object_refname_ambiguity =1 ;
@@ -342,7 +341,7 @@ int git_default_core_config(const char *var, const char *value, }if (!strcmp (var,"core.ignorecase" )) { - ignore_case =git_config_bool (var, value); + cfg->ignore_case =git_config_bool (var, value);return 0 ; }
environment.h +0 -1
@@ -171,7 +171,6 @@ extern int trust_ctime;extern int check_stat;extern int has_symlinks;extern int minimum_abbrev, default_abbrev; -extern int ignore_case;extern int assume_unchanged;extern int warn_on_object_refname_ambiguity;extern char *apply_default_whitespace;
fsmonitor.c +1 -1
@@ -453,7 +453,7 @@ static void fsmonitor_refresh_callback(struct index_state *istate, char *name)* case-insensitive file system, try again using the name-hash * and dir-name-hash. */ -if (!nr_in_cone && ignore_case) { +if (!nr_in_cone &&repo_ignore_case (the_repository)) { nr_in_cone =handle_using_name_hash_icase (istate, name);if (!nr_in_cone) nr_in_cone = handle_using_dir_name_hash_icase(
name-hash.c +3 -3
@@ -126,7 +126,7 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)hashmap_add (&istate->name_hash, &ce->ent); } -if (ignore_case) +if (repo_ignore_case (the_repository))add_dir_entry (istate, ce); }
@@ -207,7 +207,7 @@ static int lookup_lazy_params(struct index_state *istate)* code to build the "istate->name_hash". We don't * need the complexity here. */ -if (!ignore_case) +if (!repo_ignore_case (the_repository))return 0 ; nr_cpus =online_cpus ();
@@ -651,7 +651,7 @@ void remove_name_hash(struct index_state *istate, struct cache_entry *ce) ce->ce_flags &= ~CE_HASHED ;hashmap_remove (&istate->name_hash, &ce->ent, ce); -if (ignore_case) +if (repo_ignore_case (the_repository))remove_dir_entry (istate, ce); }
read-cache.c +3 -3
@@ -760,12 +760,12 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,* case of the file being added to the repository matches (is folded into) the existing * entry's directory case. */ -if (ignore_case) { +if (repo_ignore_case (the_repository)) {adjust_dirname_case (istate, ce->name); }if (!(flags &ADD_CACHE_RENORMALIZE )) { alias =index_file_exists (istate, ce->name, -ce_namelen (ce), ignore_case); +ce_namelen (ce),repo_ignore_case (the_repository));if (alias && !ce_stage (alias) && !ie_match_stat (istate, alias, st, ce_option)) {
@@ -786,7 +786,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, }else set_object_name_for_intent_to_add_entry (ce); -if (ignore_case && alias &&different_name (ce, alias)) +if (repo_ignore_case (the_repository) && alias &&different_name (ce, alias)) ce =create_alias_ce (istate, ce, alias); ce->ce_flags |=CE_ADDED ;
refs/files-backend.c +2 -2
@@ -806,7 +806,7 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs, }else {unable_to_lock_message (ref_file.buf, myerr, err);if (myerr ==EEXIST ) { -if (ignore_case && +if (repo_ignore_case (the_repository) &&transaction_has_case_conflicting_update (transaction, update)) {/* * In case-insensitive filesystems, ensure that conflicts within a
@@ -920,7 +920,7 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs,* conflicts between 'foo' and 'Foo/bar'. So let's lowercase * the refname. */ -if (ignore_case) { +if (repo_ignore_case (the_repository)) {struct strbuf lower =STRBUF_INIT ;strbuf_addstr (&lower, refname);
submodule.c +1 -1
@@ -2389,7 +2389,7 @@ static int validate_submodule_encoded_git_dir(char *git_dir, const char *submodu/* Prevent conflicts on case-folding filesystems */ repo_config_get_bool (the_repository,"core.ignorecase" , &config_ignorecase); -if (ignore_case || config_ignorecase) { +if (repo_ignore_case (the_repository) || config_ignorecase) {bool suffixes_match = !strcmp (last_submodule_name, submodule_name);return check_casefolding_conflict (git_dir, submodule_name, suffixes_match);
t/helper/test-lazy-init-name-hash.c +1 -1
@@ -218,7 +218,7 @@ int cmd__lazy_init_name_hash(int argc, const char **argv)/* * istate->dir_hash is only created when ignore_case is set. */ - ignore_case =1 ; +repo_config_values (the_repository)->ignore_case =1 ;if (dump) {if (perf || analyze >0 )
unpack-trees.c +1 -1
@@ -2428,7 +2428,7 @@ static int check_ok_to_remove(const char *name, int len, int dtype,* * Ignore that lstat() if it matches. */ -if (ignore_case &&icase_exists (o, name, len, st)) +if (repo_ignore_case (the_repository) &&icase_exists (o, name, len, st))return 0 ; if (o->internal.dir &&
Signature · 1 line
2.43.0
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Tian Yuchen
Related materials:
[1] In this patch to migrate
protect_hfsandprotect_ntfs, the approach
of introducing getters has been endorsed.
Quoted 9 lines
Quoted 2 lines
[2] Derrick Stolee's previous attempt. The reasons for the failure are
also mentioned in [1].[1] here refers to the starting message of the whole hfs/ntfs thing. Do you mean that people must read the entire thread to find out what the reasons for the failure was? For that matter, it is not clear, unless readers read the whole thread, where the approach of using getters was "endorsed", either.
What I meant to say was that the reasons were already mentioned in the _cover-letter_ for the patch which the link refers to. It’s certainly my fault for not expressing myself clearly. Nevertheless, I’ve briefly explained the content of the link directly in the cover-letter for V3.
Quoted 7 lines
Quoted 7 lines
[1] https://lore.kernel.org/git/[email protected]/
[2] https://lore.kernel.org/git/2b4198c09cb6c04c60608d19072d419503dfe5df.1685716421.git.gitgitgadget@gmail.com/Changes since V1:
- s/repo_get_ignore_case()/repo_ignore_case()
Quoted 8 lines
Quoted 1 line
- Use
repo->initializedinstead ofrepo->gitdirI do not think I have any objections to these changes from the previous iteration. There may be some other things in the new iteration but I'll have to go in and read the patches to find them out (if they exist).
Thanks.
Additionally, I’ll change 'repo->gitdir' to using 'repo->initialized' for the previous three bits as well.
Regards, yuchen
Quoted 5 lines · Tian Yuchen
This series continues the ongoing libification effort by moving this global variable into 'struct
repo_config_values', tying it to the specific repository instance it was read from. This allows us to encapsulate the configuration without altering its eager-parsing behavior.
Looks good.
Quoted 2 lines
compat/win32/path-utils.c--- Is it appropriate to include therepository.hheader file?
As the compat/ layer is not meant as a general purpose POSIX emulation wrapper that is generally reusable to projects other than us, if we have a knob settable by end users to affect behaviours of lower layer in compat/, it is natural to make repo-settings available to them.
What is the perceived problem you have in mind, and what are your proposed alternatives?
Quoted 5 lines · Junio C Hamano
As the compat/ layer is not meant as a general purpose POSIX emulation wrapper that is generally reusable to projects other than us, if we have a knob settable by end users to affect behaviours of lower layer in compat/, it is natural to make repo-settings available to them.
I see.
Quoted 2 lines
What is the perceived problem you have in mind, and what are your proposed alternatives?
Actually, my reason for showing this question wasn’t because I thought there were any architectural problem, but because I felt that for a file in compat/win32, which is more on the _downstream_ side (is that correct?), we need to exercise extra caution and confirm with its maintainer whether the changes are appropriate. That’s why I CC'd Johannes Schindelin on this.
Was that the right thing to do?
Regards, yuchen
Quoted 12 lines · Tian Yuchen
Quoted 5 lines · Junio C Hamano
As the compat/ layer is not meant as a general purpose POSIX emulation wrapper that is generally reusable to projects other than us, if we have a knob settable by end users to affect behaviours of lower layer in compat/, it is natural to make repo-settings available to them.
I see.
Quoted 2 lines
What is the perceived problem you have in mind, and what are your proposed alternatives?
Quoted 8 lines
Actually, my reason for showing this question wasn’t because I thought there were any architectural problem, but because I felt that for a file in compat/win32, which is more on the _downstream_ side (is that correct?), we need to exercise extra caution and confirm with its maintainer whether the changes are appropriate. That’s why I CC'd Johannes Schindelin on this.
Was that the right thing to do?
Yup, Dscho is the right person to decide on the design issues on Windows build.
Hi Yuchen,
Quoted 2 lines · Tian Yuchen
compat/win32/path-utils.c--- Is it appropriate to include therepository.hheader file?
Since path-utils.c implements logic that is repository-dependent (as your patch points out), including that header is appropriate.
Ciao,
Johannes
Quoted 9 lines · Johannes Schindelin
Hi Yuchen,
Quoted 2 lines · Tian Yuchen
compat/win32/path-utils.c--- Is it appropriate to include therepository.hheader file?Since
path-utils.cimplements logic that is repository-dependent (as your patch points out), including that header is appropriate.
Thanks, both. Let's merge the topic down to 'next' then.