From: drona <dronarajgyawali@gmail.com>
To: git@vger.kernel.org
Cc: Dorna Raj Gyawali <dronarajgyawali@gmail.com>
Subject: [PATCH] Make 'trust_executable_bit' repository-scoped
Date: Mon, 9 Mar 2026 00:09:21 +0545 [thread overview]
Message-ID: <20260308182424.31349-1-dronarajgyawali@gmail.com> (raw)
In-Reply-To: <20260301190017.53539-1-dronarajgyawali@gmail.com>
From: Dorna Raj Gyawali <dronarajgyawali@gmail.com>
- Moved 'trust_executable_bit' from a global variable to
struct repo_settings.
- Updated all calls to ce_mode_from_stat() to pass the repository.
- Updated environment.c to set the repository's trust_executable_bit
when reading core.filemode.
- Fixed apply.c, update-index.c, diff-lib.c, and read-cache.c to
reference the_repository->settings.trust_executable_bit.
- Added prepare_repo_settings() call in diff-lib.c to ensure repo
settings are loaded.
This change makes executable-bit handling repository-scoped and
prepares the code for multi-repo support.
Signed-off-by: Dorna Raj Gyawali <dronarajgyawali@gmail.com>
---
apply.c | 2 +-
diff-lib.c | 9 +++++----
environment.c | 1 +
3 files changed, 7 insertions(+), 5 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;
}
--
2.43.0
next prev parent reply other threads:[~2026-03-08 18:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-01 18:59 [PATCH] Refactor 'trust_executable_bit' to repository-scoped setting drona
2026-03-06 18:02 ` Tian Yuchen
2026-03-08 18:24 ` drona [this message]
2026-03-08 18:34 ` [PATCH] [PATCH v2] Make 'trust_executable_bit' repository-scoped drona
2026-03-08 18:37 ` drona
[not found] ` <f03d40072ab106d1a0a7852718d42f56@purelymail.com>
2026-03-09 7:13 ` cat
2026-03-09 13:33 ` Dronaraj Gyawali
2026-03-09 16:23 ` Tian Yuchen
2026-03-09 22:03 ` Junio C Hamano
2026-03-09 15:07 ` Junio C Hamano
2026-03-09 17:51 ` Dronaraj Gyawali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260308182424.31349-1-dronarajgyawali@gmail.com \
--to=dronarajgyawali@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox