{"thread":{"id":"65111","subject":"[PATCH] Refactor 'trust_executable_bit' to repository-scoped setting","startedAt":"2026-03-01T19:00:32Z","lastAt":"2026-03-09T22:03:56Z","messageCount":11,"participants":["drona","Tian Yuchen","cat@malon.dev","Dronaraj Gyawali","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"537468","messageId":"20260301190017.53539-1-dronarajgyawali@gmail.com","threadId":"65111","inReplyTo":null,"subject":"[PATCH] Refactor 'trust_executable_bit' to repository-scoped setting","fromName":"drona","fromEmail":"dronarajgyawali@gmail.com","sentAt":"2026-03-01T18:59:49Z","receivedAt":"2026-03-01T19:00:32Z","isPatch":true,"sender":{"key":"dronarajgyawali@gmail.com","avatar":null},"body":"From: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n\nCurrently, 'trust_executable_bit' is a global variable in environment.c,\nwhich controls how executable bits are interpreted when creating/updating\ncache entries.\n\nThis patch moves 'trust_executable_bit' into 'struct repo_settings', making\nit a repository-scoped configuration. All references in files have been updated to use\n'the_repository->settings.trust_executable_bit'.\n\nWhy this is a good candidate:\n- It's a self-contained global variable that only affects file mode logic.\n- Low risk: changes only impact mode calculations and related apply/update\n  operations.\n- Makes Git codebase more maintainable and prepares for future multi-repo\n  support.\n\n- Manual sanity check with a test repo confirms executable bits behave correctly.\n\nSigned-off-by: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n---\n apply.c                |  4 ++--\n builtin/update-index.c |  2 +-\n diff-lib.c             | 10 +++++-----\n environment.c          |  3 +--\n environment.h          |  1 -\n read-cache.c           | 10 +++++-----\n read-cache.h           | 11 +++++++----\n repo-settings.h        |  6 +++++-\n 8 files changed, 26 insertions(+), 21 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex d044c95d50..2bcb22a4bc 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3838,8 +3838,8 @@ 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 (trust_executable_bit || !S_ISREG(st->st_mode))\n-\t\t\tst_mode = ce_mode_from_stat(*ce, 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;\n \t\telse\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 8a5907767b..7917bd286f 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -293,7 +293,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len\n \tce->ce_flags = create_ce_flags(0);\n \tce->ce_namelen = len;\n \tfill_stat_cache_info(the_repository->index, ce, st);\n-\tce->ce_mode = ce_mode_from_stat(old, st->st_mode);\n+\tce->ce_mode = ce_mode_from_stat(the_repository, old, st->st_mode);\n \n \tif (index_path(the_repository->index, &ce->oid, path, st,\n \t\t       info_only ? 0 : INDEX_WRITE_OBJECT)) {\ndiff --git a/diff-lib.c b/diff-lib.c\nindex ae91027a02..894358c8b0 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -160,7 +160,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(ce, st.st_mode);\n+\t\t\t\twt_mode = ce_mode_from_stat(the_repository, 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 +193,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(nce, mode);\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].status =\n \t\t\t\t\t\tDIFF_STATUS_MODIFIED;\n \t\t\t\t}\n@@ -262,7 +262,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(ce, st.st_mode);\n+\t\t\t\tnewmode = ce_mode_from_stat(the_repository, 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 +270,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(ce, st.st_mode);\n+\t\t\tnewmode = ce_mode_from_stat(the_repository, ce, st.st_mode);\n \t\t}\n \n \t\tif (!changed && !dirty_submodule) {\n@@ -338,7 +338,7 @@ static int get_stat_data(const struct cache_entry *ce,\n \t\tchanged = match_stat_with_submodule(diffopt, ce, &st,\n \t\t\t\t\t\t    0, dirty_submodule);\n \t\tif (changed) {\n-\t\t\tmode = ce_mode_from_stat(ce, st.st_mode);\n+\t\t\tmode = ce_mode_from_stat(the_repository, ce, st.st_mode);\n \t\t\toid = null_oid(the_hash_algo);\n \t\t}\n \t}\ndiff --git a/environment.c b/environment.c\nindex 0026eb2274..861ef084dc 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -41,7 +41,6 @@\n static int pack_compression_seen;\n static int zlib_compression_seen;\n \n-int trust_executable_bit = 1;\n int trust_ctime = 1;\n int check_stat = 1;\n int has_symlinks = 1;\n@@ -306,7 +305,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\ttrust_executable_bit = git_config_bool(var, value);\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\")) {\ndiff --git a/environment.h b/environment.h\nindex 27f657af04..7f3437f369 100644\n--- a/environment.h\n+++ b/environment.h\n@@ -144,7 +144,6 @@ int is_bare_repository(void);\n extern char *git_work_tree_cfg;\n \n /* Environment bits from configuration mechanism */\n-extern int trust_executable_bit;\n extern int trust_ctime;\n extern int check_stat;\n extern int has_symlinks;\ndiff --git a/read-cache.c b/read-cache.c\nindex 0c07c3aef7..b1fcb9e1a0 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -201,13 +201,13 @@ void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, st\n \n static unsigned int st_mode_from_ce(const struct cache_entry *ce)\n {\n-\textern int trust_executable_bit, has_symlinks;\n+\textern int has_symlinks;\n \n \tswitch (ce->ce_mode & S_IFMT) {\n \tcase S_IFLNK:\n \t\treturn has_symlinks ? S_IFLNK : (S_IFREG | 0644);\n \tcase S_IFREG:\n-\t\treturn (ce->ce_mode & (trust_executable_bit ? 0755 : 0644)) | S_IFREG;\n+\t\treturn (ce->ce_mode & (the_repository->settings.trust_executable_bit ? 0755 : 0644)) | S_IFREG;\n \tcase S_IFGITLINK:\n \t\treturn S_IFDIR | 0755;\n \tcase S_IFDIR:\n@@ -317,7 +317,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)\n \t\t/* We consider only the owner x bit to be relevant for\n \t\t * \"mode changes\"\n \t\t */\n-\t\tif (trust_executable_bit &&\n+\t\tif (the_repository->settings.trust_executable_bit &&\n \t\t    (0100 & (ce->ce_mode ^ st->st_mode)))\n \t\t\tchanged |= MODE_CHANGED;\n \t\tbreak;\n@@ -738,7 +738,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n \t\tce->ce_flags |= CE_INTENT_TO_ADD;\n \n \n-\tif (trust_executable_bit && has_symlinks) {\n+\tif (the_repository->settings.trust_executable_bit && has_symlinks) {\n \t\tce->ce_mode = create_ce_mode(st_mode);\n \t} else {\n \t\t/* If there is an existing entry, pick the mode bits and type\n@@ -748,7 +748,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n \t\tint pos = index_name_pos_also_unmerged(istate, path, namelen);\n \n \t\tent = (0 <= pos) ? istate->cache[pos] : NULL;\n-\t\tce->ce_mode = ce_mode_from_stat(ent, st_mode);\n+\t\tce->ce_mode = ce_mode_from_stat(the_repository, ent, st_mode);\n \t}\n \n \t/* When core.ignorecase=true, determine if a directory of the same name but differing\ndiff --git a/read-cache.h b/read-cache.h\nindex 043da1f1aa..4e88d476aa 100644\n--- a/read-cache.h\n+++ b/read-cache.h\n@@ -4,15 +4,18 @@\n #include \"read-cache-ll.h\"\n #include \"object.h\"\n #include \"pathspec.h\"\n+#include \"repository.h\"\n \n-static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,\n-\t\t\t\t\t     unsigned int mode)\n+static inline unsigned int ce_mode_from_stat(\n+\t\t\t\t\t\tstruct repository *repo,\n+\t\t\t\t\t\tconst struct cache_entry *ce,\n+\t\t\t\t\t    unsigned int mode)\n {\n-\textern int trust_executable_bit, has_symlinks;\n+\textern int has_symlinks;\n \tif (!has_symlinks && S_ISREG(mode) &&\n \t    ce && S_ISLNK(ce->ce_mode))\n \t\treturn ce->ce_mode;\n-\tif (!trust_executable_bit && S_ISREG(mode)) {\n+\tif (!repo->settings.trust_executable_bit && S_ISREG(mode)) {\n \t\tif (ce && S_ISREG(ce->ce_mode))\n \t\t\treturn ce->ce_mode;\n \t\treturn create_ce_mode(0666);\ndiff --git a/repo-settings.h b/repo-settings.h\nindex cad9c3f0cc..a12e763f4f 100644\n--- a/repo-settings.h\n+++ b/repo-settings.h\n@@ -48,7 +48,10 @@ struct repo_settings {\n \t * replace_refs_enabled() for more details.\n \t */\n \tint read_replace_refs;\n-\n+\t\n+\t/* Whether to trust executable bit on filesystem (core.filemode) */\n+\tint trust_executable_bit;\n+\t\n \tstruct fsmonitor_settings *fsmonitor; /* lazily loaded */\n \n \tint index_version;\n@@ -74,6 +77,7 @@ struct repo_settings {\n #define REPO_SETTINGS_INIT { \\\n \t.shared_repository = -1, \\\n \t.index_version = -1, \\\n+\t.trust_executable_bit = 1, \\\n \t.core_untracked_cache = UNTRACKED_CACHE_KEEP, \\\n \t.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE, \\\n \t.warn_ambiguous_refs = -1, \\\n-- \n2.43.0\n\n"},{"id":"538099","messageId":"24f40e5a-a5fd-49ec-86e7-921b44e4abd9@gmail.com","threadId":"65111","inReplyTo":"20260301190017.53539-1-dronarajgyawali@gmail.com","subject":"Re: [PATCH] Refactor 'trust_executable_bit' to repository-scoped setting","fromName":"Tian Yuchen","fromEmail":"a3205153416@gmail.com","sentAt":"2026-03-06T18:02:18Z","receivedAt":"2026-03-06T18:02:22Z","isPatch":true,"sender":{"key":"cat@malon.dev","avatar":"https://avatars.githubusercontent.com/u/232002048?v=4"},"body":"Hi drona,\n\nOn 3/2/26 02:59, drona wrote:\n\n> This patch moves 'trust_executable_bit' into 'struct repo_settings', making\n> it a repository-scoped configuration. All references in files have been updated to use\n> 'the_repository->settings.trust_executable_bit'.\n\nThe original intent of this patch should be sound.\n\n> Why this is a good candidate:\n> - It's a self-contained global variable that only affects file mode logic.\n> - Low risk: changes only impact mode calculations and related apply/update\n>    operations.\n> - Makes Git codebase more maintainable and prepares for future multi-repo\n>    support.\n> \n> - Manual sanity check with a test repo confirms executable bits behave correctly.\n> \n> Signed-off-by: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n> ---\n>   apply.c                |  4 ++--\n>   builtin/update-index.c |  2 +-\n>   diff-lib.c             | 10 +++++-----\n>   environment.c          |  3 +--\n>   environment.h          |  1 -\n>   read-cache.c           | 10 +++++-----\n>   read-cache.h           | 11 +++++++----\n>   repo-settings.h        |  6 +++++-\n>   8 files changed, 26 insertions(+), 21 deletions(-)\n> \n> diff --git a/apply.c b/apply.c\n> index d044c95d50..2bcb22a4bc 100644\n> --- a/apply.c\n> +++ b/apply.c\n> @@ -3838,8 +3838,8 @@ 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 (trust_executable_bit || !S_ISREG(st->st_mode))\n> -\t\t\tst_mode = ce_mode_from_stat(*ce, 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;\n>   \t\telse\n\nYou can run git diff --check before committing. There's an extra space \nhere.\n\n> diff --git a/builtin/update-index.c b/builtin/update-index.c\n> index 8a5907767b..7917bd286f 100644\n> --- a/builtin/update-index.c\n> +++ b/builtin/update-index.c\n> @@ -293,7 +293,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len\n>   \tce->ce_flags = create_ce_flags(0);\n>   \tce->ce_namelen = len;\n>   \tfill_stat_cache_info(the_repository->index, ce, st);\n> -\tce->ce_mode = ce_mode_from_stat(old, st->st_mode);\n> +\tce->ce_mode = ce_mode_from_stat(the_repository, old, st->st_mode);\n>   \n>   \tif (index_path(the_repository->index, &ce->oid, path, st,\n>   \t\t       info_only ? 0 : INDEX_WRITE_OBJECT)) {\n> diff --git a/diff-lib.c b/diff-lib.c\n> index ae91027a02..894358c8b0 100644\n> --- a/diff-lib.c\n> +++ b/diff-lib.c\n> @@ -160,7 +160,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(ce, st.st_mode);\n> +\t\t\t\twt_mode = ce_mode_from_stat(the_repository, 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 +193,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(nce, mode);\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].status =\n>   \t\t\t\t\t\tDIFF_STATUS_MODIFIED;\n>   \t\t\t\t}\n> @@ -262,7 +262,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(ce, st.st_mode);\n> +\t\t\t\tnewmode = ce_mode_from_stat(the_repository, 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 +270,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(ce, st.st_mode);\n> +\t\t\tnewmode = ce_mode_from_stat(the_repository, ce, st.st_mode);\n>   \t\t}\n>   \n>   \t\tif (!changed && !dirty_submodule) {\n> @@ -338,7 +338,7 @@ static int get_stat_data(const struct cache_entry *ce,\n>   \t\tchanged = match_stat_with_submodule(diffopt, ce, &st,\n>   \t\t\t\t\t\t    0, dirty_submodule);\n>   \t\tif (changed) {\n> -\t\t\tmode = ce_mode_from_stat(ce, st.st_mode);\n> +\t\t\tmode = ce_mode_from_stat(the_repository, ce, st.st_mode);\n>   \t\t\toid = null_oid(the_hash_algo);\n>   \t\t}\n>   \t}\n> diff --git a/environment.c b/environment.c\n> index 0026eb2274..861ef084dc 100644\n> --- a/environment.c\n> +++ b/environment.c\n> @@ -41,7 +41,6 @@\n>   static int pack_compression_seen;\n>   static int zlib_compression_seen;\n>   \n> -int trust_executable_bit = 1;\n>   int trust_ctime = 1;\n>   int check_stat = 1;\n>   int has_symlinks = 1;\n\nBut the_repository itself is a global variable, isn't it?\n\nIf you understand what “removing global variables” means, you should \ngrasp the direction we're heading:\n\n\tpassing global variables -> passing context\n\nFor example, in\n\n > @@ -160,7 +160,7 @@ void run_diff_files(struct rev_info *revs, \nunsigned 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(ce, st.st_mode);\n > +\t\t\t\twt_mode = ce_mode_from_stat(the_repository, ce, st.st_mode);\n\t\t\t\tperror(ce->name);\n\nA more appropriate of passing value could be something like:\n\nwt_mode = ce_mode_from_stat(revs->repo, ce, st.st_mode)\n\n> @@ -306,7 +305,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\ttrust_executable_bit = git_config_bool(var, value);\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\nI didn't think it through, but my gut tells me there might be some weird \nvariable overwriting issues here.\n\nBut more importantly, I feel that the changes here somewhat undermine \nlazy loading behavior. Variables in repo_settings are lazy-loaded, \nmeaning you cannot read their values via actions like \nrepo->settings.trust_executable_bit because they are not loaded until \nneeded. The function prepare_repo_settings(repo) should be called to \nload the values.\n\nHowever, the change here appears to manually assign a value during the \nglobal config parsing phase. I believe this is incorrect.\n\nFor more information you can look through \nhttps://lore.kernel.org/all/48821a3848bef25c13038be8377ad73e7c17a924.1771258573.git.belkid98@gmail.com/\n\nRegards,\n\nYuchen\n\n\n\n"},{"id":"538209","messageId":"20260308182424.31349-1-dronarajgyawali@gmail.com","threadId":"65111","inReplyTo":"20260301190017.53539-1-dronarajgyawali@gmail.com","subject":"[PATCH] Make 'trust_executable_bit' repository-scoped","fromName":"drona","fromEmail":"dronarajgyawali@gmail.com","sentAt":"2026-03-08T18:24:21Z","receivedAt":"2026-03-08T18:24:46Z","isPatch":true,"sender":{"key":"dronarajgyawali@gmail.com","avatar":null},"body":"From: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n\n- Moved 'trust_executable_bit' from a global variable to\n  struct repo_settings.\n- Updated all calls to ce_mode_from_stat() to pass the repository.\n- Updated environment.c to set the repository's trust_executable_bit\n  when reading core.filemode.\n- Fixed apply.c, update-index.c, diff-lib.c, and read-cache.c to\n  reference the_repository->settings.trust_executable_bit.\n- Added prepare_repo_settings() call in diff-lib.c to ensure repo\n  settings are loaded.\n\nThis change makes executable-bit handling repository-scoped and\nprepares the code for multi-repo support.\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 3 files changed, 7 insertions(+), 5 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}\n-- \n2.43.0\n\n"},{"id":"538210","messageId":"20260308183421.31700-1-dronarajgyawali@gmail.com","threadId":"65111","inReplyTo":"20260301190017.53539-1-dronarajgyawali@gmail.com","subject":"[PATCH] [PATCH v2] Make 'trust_executable_bit' repository-scoped","fromName":"drona","fromEmail":"dronarajgyawali@gmail.com","sentAt":"2026-03-08T18:34:21Z","receivedAt":"2026-03-08T18:34:31Z","isPatch":true,"sender":{"key":"dronarajgyawali@gmail.com","avatar":null},"body":"From: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n\n- Moved 'trust_executable_bit' from a global variable to\n  struct repo_settings.\n- Updated all calls to ce_mode_from_stat() to pass the repository.\n- Updated environment.c to set the repository's trust_executable_bit\n  when reading core.filemode.\n- Fixed apply.c, update-index.c, diff-lib.c, and read-cache.c to\n  reference the_repository->settings.trust_executable_bit.\n- Added prepare_repo_settings() call in diff-lib.c to ensure repo\n  settings are loaded.\n\nThis change makes executable-bit handling repository-scoped and\nprepares the code for multi-repo support.\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 3 files changed, 7 insertions(+), 5 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}\n-- \n2.43.0\n\n"},{"id":"538211","messageId":"20260308183756.31860-1-dronarajgyawali@gmail.com","threadId":"65111","inReplyTo":"20260301190017.53539-1-dronarajgyawali@gmail.com","subject":"[PATCH v2] Make 'trust_executable_bit' repository-scoped","fromName":"drona","fromEmail":"dronarajgyawali@gmail.com","sentAt":"2026-03-08T18:37:56Z","receivedAt":"2026-03-08T18:38:06Z","isPatch":true,"sender":{"key":"dronarajgyawali@gmail.com","avatar":null},"body":"From: Dorna Raj Gyawali <dronarajgyawali@gmail.com>\n\n- Moved 'trust_executable_bit' from a global variable to\n  struct repo_settings.\n- Updated all calls to ce_mode_from_stat() to pass the repository.\n- Updated environment.c to set the repository's trust_executable_bit\n  when reading core.filemode.\n- Fixed apply.c, update-index.c, diff-lib.c, and read-cache.c to\n  reference the_repository->settings.trust_executable_bit.\n- Added prepare_repo_settings() call in diff-lib.c to ensure repo\n  settings are loaded.\n\nThis change makes executable-bit handling repository-scoped and\nprepares the code for multi-repo support.\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 3 files changed, 7 insertions(+), 5 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}\n-- \n2.43.0\n\n"},{"id":"538253","messageId":"6e3d373f2f41232ca9015c39ae0ea67d@purelymail.com","threadId":"65111","inReplyTo":"f03d40072ab106d1a0a7852718d42f56@purelymail.com","subject":"Re: [PATCH v2] Make 'trust_executable_bit' repository-scoped","fromName":"","fromEmail":"cat@malon.dev","sentAt":"2026-03-09T07:13:34Z","receivedAt":"2026-03-09T07:13:40Z","isPatch":true,"sender":{"key":"cat@malon.dev","avatar":"https://avatars.githubusercontent.com/u/232002048?v=4"},"body":"> Hi drona,\n> \n> Thanks for the update! Just a quick heads-up: it looks like\n> you forgot to CC Junio (gitster@pobox.com) on this iteration.\n> Additionally, I think it's a good practice to respond to\n> reviews before sending new patches. What do you think?\n> \n>>  \tif (!strcmp(var, \"core.filemode\")) {\n>> +\t\tprepare_repo_settings(the_repository);\n>>  \t\tthe_repository->settings.trust_executable_bit = \n>> git_config_bool(var, value);\n>>  \t\treturn 0;\n>>  \t}\n> \n> Regarding the code, calling 'prepare_repo_settings()' inside\n> 'git_default_core_config()' defeats the purpose of lazy-loading,\n> doesn't it?\n> \n> if (!strcmp(var, \"core.filemode\")) {\n> \tprepare_repo_settings(the_repository);\n> \tthe_repository->settings.trust_executable_bit = git_config_bool(var, \n> value);\n> \treturn 0;\n> }\n> \n> I think the standard practice is to drop the variable from\n> 'environment.c' completely and read it directly inside\n> 'repo-settings.c: prepare_repo_settings()' using\n> 'repo_config_get_bool()'.\n> \n> Regards,\n> \n> Yuchen\n\nI accidentally clicked the wrong option and didn't select Reply All.\n\nI'll CC Junio on this message.\n\nRegards,\n\nYuchen\n"},{"id":"538263","messageId":"CAJtK1FMzbX7dO9y7hM_6_DbLpwbeYHnrg7WLjAghGX6UDVDmJw@mail.gmail.com","threadId":"65111","inReplyTo":"6e3d373f2f41232ca9015c39ae0ea67d@purelymail.com","subject":"Re: [PATCH v2] Make 'trust_executable_bit' repository-scoped","fromName":"Dronaraj Gyawali","fromEmail":"dronarajgyawali@gmail.com","sentAt":"2026-03-09T13:33:19Z","receivedAt":"2026-03-09T13:33:33Z","isPatch":true,"sender":{"key":"dronarajgyawali@gmail.com","avatar":null},"body":"Hi Yuchen,\n\nThanks for the review and for pointing that out.\n\nYou're right that calling prepare_repo_settings() inside\ngit_default_core_config() defeats the purpose of lazy loading. I'll\nupdate the patch accordingly by removing the handling from\nenvironment.c and reading core.filemode directly in repo-settings.c\nusing repo_config_get_bool().\n\nAlso, I'm new to contributing to Git, so thank you for the guidance\nand patience while I learn.\n\nThanks again for the help.\n\nRegards,\nDrona\n"},{"id":"538283","messageId":"xmqq1pht6nyx.fsf@gitster.g","threadId":"65111","inReplyTo":"6e3d373f2f41232ca9015c39ae0ea67d@purelymail.com","subject":"Re: [PATCH v2] Make 'trust_executable_bit' repository-scoped","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-09T15:07:18Z","receivedAt":"2026-03-09T15:07:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"cat@malon.dev writes:\n\n>> Hi drona,\n>> \n>> Thanks for the update! Just a quick heads-up: it looks like\n>> you forgot to CC Junio (gitster@pobox.com) on this iteration.\n\nNo strong need to Cc the maintainer when the patch is not ready to\nbe applied, even though it may be nice.  I'll be seeing it either\nway as I rarely look at my mailbox and use the mailing list archive\nat lore.kernel.org my primary source of Git patches anyway.\n\nThere were discussions on pros and cons moving global recipients of\nconfiguration values into a dynamically allocated strucrure, which\ncan change when they are parsed and when bad values in them result\nin warnings, depending on the way the change is done, and excellent\npieces of advice have been given by Phillip Wood.  If anything, a\nchange like this should ask for input from him.\n\n>> Additionally, I think it's a good practice to respond to\n>> reviews before sending new patches.\n\nAbsolutely.\n\n>>>  \tif (!strcmp(var, \"core.filemode\")) {\n>>> +\t\tprepare_repo_settings(the_repository);\n>>>  \t\tthe_repository->settings.trust_executable_bit = \n>>> git_config_bool(var, value);\n>>>  \t\treturn 0;\n>>>  \t}\n>> \n>> Regarding the code, calling 'prepare_repo_settings()' inside\n>> 'git_default_core_config()' defeats the purpose of lazy-loading,\n>> doesn't it?\n>> \n>> if (!strcmp(var, \"core.filemode\")) {\n>> \tprepare_repo_settings(the_repository);\n>> \tthe_repository->settings.trust_executable_bit = git_config_bool(var, \n>> value);\n>> \treturn 0;\n>> }\n>> \n>> I think the standard practice is to drop the variable from\n>> 'environment.c' completely and read it directly inside\n>> 'repo-settings.c: prepare_repo_settings()' using\n>> 'repo_config_get_bool()'.\n\nThis \"v2\" applies to a mythical codebase where trust_executable_bit\nis somehow a member in the settings structure, which I do not think\nwe have.\n\n"},{"id":"538296","messageId":"615caf83-71be-43a6-bcb0-3a0c5e14d699@malon.dev","threadId":"65111","inReplyTo":"CAJtK1FMzbX7dO9y7hM_6_DbLpwbeYHnrg7WLjAghGX6UDVDmJw@mail.gmail.com","subject":"Re: [PATCH v2] Make 'trust_executable_bit' repository-scoped","fromName":"Tian Yuchen","fromEmail":"cat@malon.dev","sentAt":"2026-03-09T16:23:17Z","receivedAt":"2026-03-09T16:23:23Z","isPatch":true,"sender":{"key":"cat@malon.dev","avatar":"https://avatars.githubusercontent.com/u/232002048?v=4"},"body":"Hi drona,\n\nJunio C Hamano <gitster@pobox.com> writes:\n\n > There were discussions on pros and cons moving global recipients of\n > configuration values into a dynamically allocated strucrure...\n > and excellent pieces of advice have been given by Phillip Wood.\n > If anything, a change like this should ask for input from him.\n\nThat makes sense. I think you should CC him whenever you've thoroughly \npolished the patch or when you encounter unresolved issues.\n\n > This \"v2\" applies to a mythical codebase where trust_executable_bit\n > is somehow a member in the settings structure, which I do not think\n > we have.\n\nGiven Junio's observation, it seems this iteration is targeting an \nincorrect or non-existent codebase structure.\n\nI'll hold off on further reviews of the specific implementation details\nuntil the base codebase issue is sorted out and the structural design\n(incorporating Phillip's previous advice) is settled.\n\nLooking forward to the updated version!\n\nThanks,\n\nYuchen\n"},{"id":"538305","messageId":"CAJtK1FO56BhCo7DgtFVgMRi9yNv92_jV1i1LfEx_G2uauR+jnw@mail.gmail.com","threadId":"65111","inReplyTo":"xmqq1pht6nyx.fsf@gitster.g","subject":"Re: [PATCH v2] Make 'trust_executable_bit' repository-scoped","fromName":"Dronaraj Gyawali","fromEmail":"dronarajgyawali@gmail.com","sentAt":"2026-03-09T17:51:36Z","receivedAt":"2026-03-09T17:51:49Z","isPatch":true,"sender":{"key":"dronarajgyawali@gmail.com","avatar":null},"body":"Hi Junio,\n\nI have sent a new updated series of changes  that aligns with the\nactual code structure.\nThere was some confusion regarding work flow by my side. I am still learning..\n\nThanks for earlier review and guidance.\n\nBest regards,\ndorna\n\nOn Mon, 9 Mar 2026 at 20:52, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> cat@malon.dev writes:\n>\n> >> Hi drona,\n> >>\n> >> Thanks for the update! Just a quick heads-up: it looks like\n> >> you forgot to CC Junio (gitster@pobox.com) on this iteration.\n>\n> No strong need to Cc the maintainer when the patch is not ready to\n> be applied, even though it may be nice.  I'll be seeing it either\n> way as I rarely look at my mailbox and use the mailing list archive\n> at lore.kernel.org my primary source of Git patches anyway.\n>\n> There were discussions on pros and cons moving global recipients of\n> configuration values into a dynamically allocated strucrure, which\n> can change when they are parsed and when bad values in them result\n> in warnings, depending on the way the change is done, and excellent\n> pieces of advice have been given by Phillip Wood.  If anything, a\n> change like this should ask for input from him.\n>\n> >> Additionally, I think it's a good practice to respond to\n> >> reviews before sending new patches.\n>\n> Absolutely.\n>\n> >>>     if (!strcmp(var, \"core.filemode\")) {\n> >>> +           prepare_repo_settings(the_repository);\n> >>>             the_repository->settings.trust_executable_bit =\n> >>> git_config_bool(var, value);\n> >>>             return 0;\n> >>>     }\n> >>\n> >> Regarding the code, calling 'prepare_repo_settings()' inside\n> >> 'git_default_core_config()' defeats the purpose of lazy-loading,\n> >> doesn't it?\n> >>\n> >> if (!strcmp(var, \"core.filemode\")) {\n> >>      prepare_repo_settings(the_repository);\n> >>      the_repository->settings.trust_executable_bit = git_config_bool(var,\n> >> value);\n> >>      return 0;\n> >> }\n> >>\n> >> I think the standard practice is to drop the variable from\n> >> 'environment.c' completely and read it directly inside\n> >> 'repo-settings.c: prepare_repo_settings()' using\n> >> 'repo_config_get_bool()'.\n>\n> This \"v2\" applies to a mythical codebase where trust_executable_bit\n> is somehow a member in the settings structure, which I do not think\n> we have.\n>\n"},{"id":"538325","messageId":"xmqqo6kw3bjp.fsf@gitster.g","threadId":"65111","inReplyTo":"615caf83-71be-43a6-bcb0-3a0c5e14d699@malon.dev","subject":"Re: [PATCH v2] Make 'trust_executable_bit' repository-scoped","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-09T22:03:54Z","receivedAt":"2026-03-09T22:03:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tian Yuchen <cat@malon.dev> writes:\n\n> Hi drona,\n>\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>  > There were discussions on pros and cons moving global recipients of\n>  > configuration values into a dynamically allocated strucrure...\n>  > and excellent pieces of advice have been given by Phillip Wood.\n>  > If anything, a change like this should ask for input from him.\n>\n> That makes sense. I think you should CC him whenever you've thoroughly \n> polished the patch or when you encounter unresolved issues.\n>\n>  > This \"v2\" applies to a mythical codebase where trust_executable_bit\n>  > is somehow a member in the settings structure, which I do not think\n>  > we have.\n>\n> Given Junio's observation, it seems this iteration is targeting an \n> incorrect or non-existent codebase structure.\n>\n> I'll hold off on further reviews of the specific implementation details\n> until the base codebase issue is sorted out and the structural design\n> (incorporating Phillip's previous advice) is settled.\n\nI think what the author called v2 was actually [2/N] where the\nprevious version was treated as [1/N] of the same series.  The line\nI noticed was strange in my response is probably correcting what the\nprevious one did, which is not what we want to see.  It probably is\nsimilar to https://lore.kernel.org/git/xmqqh5qxzzzn.fsf@gitster.g/\n\nWe prefer the patch authors to pretend to be a perfect developer who\nnever made any mistakes while writing their series.\n\nThis unfortunately is a recurring theme among new developers.\n\nhttps://lore.kernel.org/git/xmqqk29bsz2o.fsf@gitster.mtv.corp.google.com/\nhttps://lore.kernel.org/git/xmqqd0ds5ysq.fsf@gitster-ct.c.googlers.com/\nhttps://lore.kernel.org/git/xmqqr173faez.fsf@gitster.g/\n"}]}