refs: support symrefs in 'reference-transaction' hook
[git.git] / read-cache.h
blob043da1f1aae706746ea46544a9dfbf0fae6c8f55
1 #ifndef READ_CACHE_H
2 #define READ_CACHE_H
4 #include "read-cache-ll.h"
5 #include "object.h"
6 #include "pathspec.h"
8 static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
9 unsigned int mode)
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);
20 return create_ce_mode(mode);
23 static inline int ce_to_dtype(const struct cache_entry *ce)
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;
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)
41 return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
42 S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
45 #endif /* READ_CACHE_H */