* [PATCH 2/3] repo-settings: move trust_executable_bit to repo_settings
@ 2026-03-09 17:12 drona
2026-03-09 17:12 ` [PATCH 3/3] repo-settings: lazy-load core.filemode in prepare_repo_settings drona
0 siblings, 1 reply; 2+ messages in thread
From: drona @ 2026-03-09 17:12 UTC (permalink / raw)
To: git; +Cc: gitster, Dorna Raj Gyawali
From: Dorna Raj Gyawali <dronarajgyawali@gmail•com>
Move trust_executable_bit from a global variable in environment.c
into struct repo_settings so it becomes repository-scoped.
v3:
- Use revs->repo instead of the_repository in diff-lib.c
- Add prepare_repo_settings() before accessing repo settings
- Minor formatting fixes
- Include recent one-line change in <filename>
Signed-off-by: Dorna Raj Gyawali <dronarajgyawali@gmail•com>
---
apply.c | 2 +-
diff-lib.c | 9 +++++----
environment.c | 1 +
repo-settings.h | 4 ++--
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/apply.c b/apply.c
index f9fd7b0030..1677ddca15 100644
--- a/apply.c
+++ b/apply.c
@@ -3838,7 +3838,7 @@ static int check_preimage(struct apply_state *state,
if (*ce && !(*ce)->ce_mode)
BUG("ce_mode == 0 for path '%s'", old_name);
- if (the_repository->settings.trust_executable_bit || !S_ISREG(st->st_mode))
+ if (the_repository->settings.trust_executable_bit || !S_ISREG(st->st_mode))
st_mode = ce_mode_from_stat(the_repository, *ce, st->st_mode);
else if (*ce)
st_mode = (*ce)->ce_mode;
diff --git a/diff-lib.c b/diff-lib.c
index 894358c8b0..276efef407 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -108,6 +108,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
void run_diff_files(struct rev_info *revs, unsigned int option)
{
+ prepare_repo_settings(revs->repo);
int entries, i;
int diff_unmerged_stage = revs->max_count;
unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
@@ -160,7 +161,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
changed = check_removed(ce, &st);
if (!changed)
- wt_mode = ce_mode_from_stat(the_repository, ce, st.st_mode);
+ wt_mode = ce_mode_from_stat(revs->repo, ce, st.st_mode);
else {
if (changed < 0) {
perror(ce->name);
@@ -193,7 +194,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
num_compare_stages++;
oidcpy(&dpath->parent[stage - 2].oid,
&nce->oid);
- dpath->parent[stage-2].mode = ce_mode_from_stat(the_repository,nce, mode);
+ dpath->parent[stage-2].mode = ce_mode_from_stat(revs->repo, nce, mode);
dpath->parent[stage-2].status =
DIFF_STATUS_MODIFIED;
}
@@ -262,7 +263,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
continue;
} else if (revs->diffopt.ita_invisible_in_index &&
ce_intent_to_add(ce)) {
- newmode = ce_mode_from_stat(the_repository, ce, st.st_mode);
+ newmode = ce_mode_from_stat(revs->repo, ce, st.st_mode);
diff_addremove(&revs->diffopt, '+', newmode,
null_oid(the_hash_algo), 0, ce->name, 0);
continue;
@@ -270,7 +271,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
ce_option, &dirty_submodule);
- newmode = ce_mode_from_stat(the_repository, ce, st.st_mode);
+ newmode = ce_mode_from_stat(revs->repo, ce, st.st_mode);
}
if (!changed && !dirty_submodule) {
diff --git a/environment.c b/environment.c
index 591683ce8c..9d12c5fa56 100644
--- a/environment.c
+++ b/environment.c
@@ -304,6 +304,7 @@ int git_default_core_config(const char *var, const char *value,
/* This needs a better name */
if (!strcmp(var, "core.filemode")) {
+ prepare_repo_settings(the_repository);
the_repository->settings.trust_executable_bit = git_config_bool(var, value);
return 0;
}
diff --git a/repo-settings.h b/repo-settings.h
index a12e763f4f..4ec9fe3280 100644
--- a/repo-settings.h
+++ b/repo-settings.h
@@ -48,10 +48,10 @@ struct repo_settings {
* replace_refs_enabled() for more details.
*/
int read_replace_refs;
-
+
/* Whether to trust executable bit on filesystem (core.filemode) */
int trust_executable_bit;
-
+
struct fsmonitor_settings *fsmonitor; /* lazily loaded */
int index_version;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 3/3] repo-settings: lazy-load core.filemode in prepare_repo_settings
2026-03-09 17:12 [PATCH 2/3] repo-settings: move trust_executable_bit to repo_settings drona
@ 2026-03-09 17:12 ` drona
0 siblings, 0 replies; 2+ messages in thread
From: drona @ 2026-03-09 17:12 UTC (permalink / raw)
To: git; +Cc: gitster, Dorna Raj Gyawali
From: Dorna Raj Gyawali <dronarajgyawali@gmail•com>
- Removed direct handling of core.filemode from environment.c.
- Moved trust_executable_bit assignment to prepare_repo_settings() in repo-settings.c
using repo_config_get_bool().
- Updated all references in apply.c, update-index.c, diff-lib.c, and read-cache.c
to use the_repository->settings.trust_executable_bit.
- Ensures repository-scoped settings and preserves lazy-loading semantics.
- No changes needed in git_default_core_config().
Signed-off-by: Dorna Raj Gyawali <dronarajgyawali@gmail•com>
---
environment.c | 6 ------
repo-settings.c | 3 +++
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/environment.c b/environment.c
index 9d12c5fa56..efec0758b7 100644
--- a/environment.c
+++ b/environment.c
@@ -302,12 +302,6 @@ int git_default_core_config(const char *var, const char *value,
{
struct repo_config_values *cfg = repo_config_values(the_repository);
- /* This needs a better name */
- if (!strcmp(var, "core.filemode")) {
- prepare_repo_settings(the_repository);
- the_repository->settings.trust_executable_bit = git_config_bool(var, value);
- return 0;
- }
if (!strcmp(var, "core.trustctime")) {
trust_ctime = git_config_bool(var, value);
return 0;
diff --git a/repo-settings.c b/repo-settings.c
index 208e09ff17..0e44825a18 100644
--- a/repo-settings.c
+++ b/repo-settings.c
@@ -85,6 +85,9 @@ void prepare_repo_settings(struct repository *r)
r->settings.pack_use_bitmap_boundary_traversal);
repo_cfg_bool(r, "core.usereplacerefs", &r->settings.read_replace_refs, 1);
+ /* Lazy-load core.filemode here */
+ repo_cfg_bool(r, "core.filemode", &r->settings.trust_executable_bit, 1);
+
/*
* The GIT_TEST_MULTI_PACK_INDEX variable is special in that
* either it *or* the config sets
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-09 17:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 17:12 [PATCH 2/3] repo-settings: move trust_executable_bit to repo_settings drona
2026-03-09 17:12 ` [PATCH 3/3] repo-settings: lazy-load core.filemode in prepare_repo_settings drona
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox