]> git.ipfire.org Git - thirdparty/git.git/blob - read-cache.h
The twelfth batch
[thirdparty/git.git] / read-cache.h
1 #ifndef READ_CACHE_H
2 #define READ_CACHE_H
3
4 #include "read-cache-ll.h"
5 #include "object.h"
6 #include "pathspec.h"
7
8 static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
9 unsigned int mode)
10 {
11 extern int trust_executable_bit, has_symlinks;
12 if (!has_symlinks && S_ISREG(mode) &&
13 ce && S_ISLNK(ce->ce_mode))
14 return ce->ce_mode;
15 if (!trust_executable_bit && S_ISREG(mode)) {
16 if (ce && S_ISREG(ce->ce_mode))
17 return ce->ce_mode;
18 return create_ce_mode(0666);
19 }
20 return create_ce_mode(mode);
21 }
22
23 static inline int ce_to_dtype(const struct cache_entry *ce)
24 {
25 unsigned ce_mode = ntohl(ce->ce_mode);
26 if (S_ISREG(ce_mode))
27 return DT_REG;
28 else if (S_ISDIR(ce_mode) || S_ISGITLINK(ce_mode))
29 return DT_DIR;
30 else if (S_ISLNK(ce_mode))
31 return DT_LNK;
32 else
33 return DT_UNKNOWN;
34 }
35
36 static inline int ce_path_match(struct index_state *istate,
37 const struct cache_entry *ce,
38 const struct pathspec *pathspec,
39 char *seen)
40 {
41 return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
42 S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
43 }
44
45 #endif /* READ_CACHE_H */