interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / read-cache.h

53 lines · 1412 bytes Raw Blame History
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#include "environment.h"
8
9/*
10 * Determine the appropriate index mode for a file based on its stat()
11 * information and the existing cache entry (if any).
12 *
13 * This function handles degradation for filesystems that lack
14 * symlink support or reliable executable bits.
15 */
16static inline unsigned int ce_mode_from_stat(struct repository *repo,
17 const struct cache_entry *ce,
18 unsigned int mode)
19{
20 if (S_ISREG(mode) && !repo_has_symlinks(repo) &&
21 ce && S_ISLNK(ce->ce_mode))
22 return ce->ce_mode;
23 if (S_ISREG(mode) && !repo_trust_executable_bit(repo)) {
24 if (ce && S_ISREG(ce->ce_mode))
25 return ce->ce_mode;
26 return create_ce_mode(0666);
27 }
28 return create_ce_mode(mode);
29}
30
31static inline int ce_to_dtype(const struct cache_entry *ce)
32{
33 unsigned ce_mode = ntohl(ce->ce_mode);
34 if (S_ISREG(ce_mode))
35 return DT_REG;
36 else if (S_ISDIR(ce_mode) || S_ISGITLINK(ce_mode))
37 return DT_DIR;
38 else if (S_ISLNK(ce_mode))
39 return DT_LNK;
40 else
41 return DT_UNKNOWN;
42}
43
44static inline int ce_path_match(struct index_state *istate,
45 const struct cache_entry *ce,
46 const struct pathspec *pathspec,
47 char *seen)
48{
49 return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
50 S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
51}
52
53#endif /* READ_CACHE_H */