From: Tian Yuchen Date: Sat, 30 May 2026 16:05:17 GMT Subject: [PATCH v1 2/4] read-cache: move 'ce_mode_from_stat()' to 'read-cache.c' Message-ID: <20260530160520.77859-3-cat@malon.dev> In-Reply-To: <20260530160520.77859-1-cat@malon.dev> The ce_mode_from_stat() function is declared as a static inline function in 'read-cache.h'. As we want to migrate configuration variables, this helper function will need access to corresponding repository-specific configuration logic. Move the implementation to 'read-cache.c' to cleanly encapsulate its dependencies. Note that the 'extern int trust_executable_bit, has_symlinks;' line is discarded because it's not necessary when the function lives in "read-cache.c". Mentored-by: Christian Couder Mentored-by: Ayush Chandekar Mentored-by: Olamide Caleb Bello Signed-off-by: Tian Yuchen --- read-cache.c | 13 +++++++++++++ read-cache.h | 16 ++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/read-cache.c b/read-cache.c index c44e4d128f..54150fe756 100644 --- a/read-cache.c +++ b/read-cache.c @@ -202,6 +202,19 @@ void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, st } } +unsigned int ce_mode_from_stat(const struct cache_entry *ce, unsigned int mode) +{ + if (!has_symlinks && S_ISREG(mode) && + ce && S_ISLNK(ce->ce_mode)) + return ce->ce_mode; + if (!trust_executable_bit && S_ISREG(mode)) { + if (ce && S_ISREG(ce->ce_mode)) + return ce->ce_mode; + return create_ce_mode(0666); + } + return create_ce_mode(mode); +} + static unsigned int st_mode_from_ce(const struct cache_entry *ce) { switch (ce->ce_mode & S_IFMT) { diff --git a/read-cache.h b/read-cache.h index 043da1f1aa..3c4af2faeb 100644 --- a/read-cache.h +++ b/read-cache.h @@ -5,20 +5,8 @@ #include "object.h" #include "pathspec.h" -static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce, - unsigned int mode) -{ - extern int trust_executable_bit, has_symlinks; - if (!has_symlinks && S_ISREG(mode) && - ce && S_ISLNK(ce->ce_mode)) - return ce->ce_mode; - if (!trust_executable_bit && S_ISREG(mode)) { - if (ce && S_ISREG(ce->ce_mode)) - return ce->ce_mode; - return create_ce_mode(0666); - } - return create_ce_mode(mode); -} +unsigned int ce_mode_from_stat(const struct cache_entry *ce, + unsigned int mode); static inline int ce_to_dtype(const struct cache_entry *ce) { -- 2.43.0