mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-13 08:57:56 -05:00
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". At present, this change has no visible impact, but it is crucial for our future plans to pass in the repo context. Comment has been added whilst we are at it. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com> Mentored-by: Olamide Caleb Bello <belkid98@gmail.com> Signed-off-by: Tian Yuchen <cat@malon.dev> Signed-off-by: Junio C Hamano <gitster@pobox.com>
41 lines
1.0 KiB
C
41 lines
1.0 KiB
C
#ifndef READ_CACHE_H
|
|
#define READ_CACHE_H
|
|
|
|
#include "read-cache-ll.h"
|
|
#include "object.h"
|
|
#include "pathspec.h"
|
|
|
|
/*
|
|
* Determine the appropriate index mode for a file based on its stat()
|
|
* information and the existing cache entry (if any).
|
|
*
|
|
* This function handles degradation for filesystems that lack
|
|
* symlink support or reliable executable bits.
|
|
*/
|
|
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)
|
|
{
|
|
unsigned ce_mode = ntohl(ce->ce_mode);
|
|
if (S_ISREG(ce_mode))
|
|
return DT_REG;
|
|
else if (S_ISDIR(ce_mode) || S_ISGITLINK(ce_mode))
|
|
return DT_DIR;
|
|
else if (S_ISLNK(ce_mode))
|
|
return DT_LNK;
|
|
else
|
|
return DT_UNKNOWN;
|
|
}
|
|
|
|
static inline int ce_path_match(struct index_state *istate,
|
|
const struct cache_entry *ce,
|
|
const struct pathspec *pathspec,
|
|
char *seen)
|
|
{
|
|
return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
|
|
S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
|
|
}
|
|
|
|
#endif /* READ_CACHE_H */
|