Subject: Re: [PATCH v1 2/4] read-cache: move 'ce_mode_from_stat()' to 'read-cache.c'

From: Patrick Steinhardt <[email-masked]>
Date: Thu, 4 Jun 2026 08:47:44 +0200

On Sun, May 31, 2026 at 12:05:17AM +0800, Tian Yuchen wrote:
> 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);

This is moving goalposts a bit, so please feel free to ignore: should we
maybe add a small comment what the function does while at it?

Patrick