{"thread":{"id":"65180","subject":"[PATCH 2/3] repo-settings: move trust_executable_bit to repo_settings","startedAt":"2026-03-09T17:12:22Z","lastAt":"2026-03-09T17:12:24Z","messageCount":2,"participants":["drona"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"538300","messageId":"20260309171216.13339-1-dronarajgyawali@gmail.com","threadId":"65180","inReplyTo":null,"subject":"[PATCH 2/3] repo-settings: move trust_executable_bit to repo_settings","fromName":"drona","fromEmail":"dronarajgyawali@gmail.com","sentAt":"2026-03-09T17:12:15Z","receivedAt":"2026-03-09T17:12:22Z","isPatch":true,"sender":{"key":"dronarajgyawali@gmail.com","avatar":null},"body":"From: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n\nMove trust_executable_bit from a global variable in environment.c\ninto struct repo_settings so it becomes repository-scoped.\n\nv3:\n- Use revs->repo instead of the_repository in diff-lib.c\n- Add prepare_repo_settings() before accessing repo settings\n- Minor formatting fixes\n- Include recent one-line change in <filename>\n\nSigned-off-by: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n---\n apply.c         | 2 +-\n diff-lib.c      | 9 +++++----\n environment.c   | 1 +\n repo-settings.h | 4 ++--\n 4 files changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex f9fd7b0030..1677ddca15 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3838,7 +3838,7 @@ static int check_preimage(struct apply_state *state,\n \t\tif (*ce && !(*ce)->ce_mode)\n \t\t\tBUG(\"ce_mode == 0 for path '%s'\", old_name);\n \n-\t\tif (the_repository->settings.trust_executable_bit  || !S_ISREG(st->st_mode))\n+\t\tif (the_repository->settings.trust_executable_bit || !S_ISREG(st->st_mode))\n \t\t\tst_mode = ce_mode_from_stat(the_repository, *ce, st->st_mode);\n \t\telse if (*ce)\n \t\t\tst_mode = (*ce)->ce_mode;\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 894358c8b0..276efef407 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -108,6 +108,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n \n void run_diff_files(struct rev_info *revs, unsigned int option)\n {\n+\tprepare_repo_settings(revs->repo);\n \tint entries, i;\n \tint diff_unmerged_stage = revs->max_count;\n \tunsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)\n@@ -160,7 +161,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)\n \n \t\t\tchanged = check_removed(ce, &st);\n \t\t\tif (!changed)\n-\t\t\t\twt_mode = ce_mode_from_stat(the_repository, ce, st.st_mode);\n+\t\t\t\twt_mode = ce_mode_from_stat(revs->repo, ce, st.st_mode);\n \t\t\telse {\n \t\t\t\tif (changed < 0) {\n \t\t\t\t\tperror(ce->name);\n@@ -193,7 +194,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)\n \t\t\t\t\tnum_compare_stages++;\n \t\t\t\t\toidcpy(&dpath->parent[stage - 2].oid,\n \t\t\t\t\t       &nce->oid);\n-\t\t\t\t\tdpath->parent[stage-2].mode = ce_mode_from_stat(the_repository,nce, mode);\n+\t\t\t\t\tdpath->parent[stage-2].mode = ce_mode_from_stat(revs->repo, nce, mode);\n \t\t\t\t\tdpath->parent[stage-2].status =\n \t\t\t\t\t\tDIFF_STATUS_MODIFIED;\n \t\t\t\t}\n@@ -262,7 +263,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)\n \t\t\t\tcontinue;\n \t\t\t} else if (revs->diffopt.ita_invisible_in_index &&\n \t\t\t\t   ce_intent_to_add(ce)) {\n-\t\t\t\tnewmode = ce_mode_from_stat(the_repository, ce, st.st_mode);\n+\t\t\t\tnewmode = ce_mode_from_stat(revs->repo, ce, st.st_mode);\n \t\t\t\tdiff_addremove(&revs->diffopt, '+', newmode,\n \t\t\t\t\t       null_oid(the_hash_algo), 0, ce->name, 0);\n \t\t\t\tcontinue;\n@@ -270,7 +271,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)\n \n \t\t\tchanged = match_stat_with_submodule(&revs->diffopt, ce, &st,\n \t\t\t\t\t\t\t    ce_option, &dirty_submodule);\n-\t\t\tnewmode = ce_mode_from_stat(the_repository, ce, st.st_mode);\n+\t\t\tnewmode = ce_mode_from_stat(revs->repo, ce, st.st_mode);\n \t\t}\n \n \t\tif (!changed && !dirty_submodule) {\ndiff --git a/environment.c b/environment.c\nindex 591683ce8c..9d12c5fa56 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -304,6 +304,7 @@ int git_default_core_config(const char *var, const char *value,\n \n \t/* This needs a better name */\n \tif (!strcmp(var, \"core.filemode\")) {\n+\t\tprepare_repo_settings(the_repository);\n \t\tthe_repository->settings.trust_executable_bit = git_config_bool(var, value);\n \t\treturn 0;\n \t}\ndiff --git a/repo-settings.h b/repo-settings.h\nindex a12e763f4f..4ec9fe3280 100644\n--- a/repo-settings.h\n+++ b/repo-settings.h\n@@ -48,10 +48,10 @@ struct repo_settings {\n \t * replace_refs_enabled() for more details.\n \t */\n \tint read_replace_refs;\n-\t\n+\n \t/* Whether to trust executable bit on filesystem (core.filemode) */\n \tint trust_executable_bit;\n-\t\n+\n \tstruct fsmonitor_settings *fsmonitor; /* lazily loaded */\n \n \tint index_version;\n-- \n2.43.0\n\n"},{"id":"538301","messageId":"20260309171216.13339-2-dronarajgyawali@gmail.com","threadId":"65180","inReplyTo":"20260309171216.13339-1-dronarajgyawali@gmail.com","subject":"[PATCH 3/3] repo-settings: lazy-load core.filemode in prepare_repo_settings","fromName":"drona","fromEmail":"dronarajgyawali@gmail.com","sentAt":"2026-03-09T17:12:16Z","receivedAt":"2026-03-09T17:12:24Z","isPatch":true,"sender":{"key":"dronarajgyawali@gmail.com","avatar":null},"body":"From: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n\n- Removed direct handling of core.filemode from environment.c.\n- Moved trust_executable_bit assignment to prepare_repo_settings() in repo-settings.c\n  using repo_config_get_bool().\n- Updated all references in apply.c, update-index.c, diff-lib.c, and read-cache.c\n  to use the_repository->settings.trust_executable_bit.\n- Ensures repository-scoped settings and preserves lazy-loading semantics.\n- No changes needed in git_default_core_config().\n\nSigned-off-by: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n---\n environment.c   | 6 ------\n repo-settings.c | 3 +++\n 2 files changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/environment.c b/environment.c\nindex 9d12c5fa56..efec0758b7 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -302,12 +302,6 @@ int git_default_core_config(const char *var, const char *value,\n {\n \tstruct repo_config_values *cfg = repo_config_values(the_repository);\n \n-\t/* This needs a better name */\n-\tif (!strcmp(var, \"core.filemode\")) {\n-\t\tprepare_repo_settings(the_repository);\n-\t\tthe_repository->settings.trust_executable_bit = git_config_bool(var, value);\n-\t\treturn 0;\n-\t}\n \tif (!strcmp(var, \"core.trustctime\")) {\n \t\ttrust_ctime = git_config_bool(var, value);\n \t\treturn 0;\ndiff --git a/repo-settings.c b/repo-settings.c\nindex 208e09ff17..0e44825a18 100644\n--- a/repo-settings.c\n+++ b/repo-settings.c\n@@ -85,6 +85,9 @@ void prepare_repo_settings(struct repository *r)\n \t\t      r->settings.pack_use_bitmap_boundary_traversal);\n \trepo_cfg_bool(r, \"core.usereplacerefs\", &r->settings.read_replace_refs, 1);\n \n+\t/* Lazy-load core.filemode here */\n+\trepo_cfg_bool(r, \"core.filemode\", &r->settings.trust_executable_bit, 1);\n+\n \t/*\n \t * The GIT_TEST_MULTI_PACK_INDEX variable is special in that\n \t * either it *or* the config sets\n-- \n2.43.0\n\n"}]}