diff options
Diffstat (limited to 'src/attrcache.h')
-rw-r--r-- | src/attrcache.h | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/attrcache.h b/src/attrcache.h index 4f9cff6bb..8e7f022b0 100644 --- a/src/attrcache.h +++ b/src/attrcache.h @@ -9,11 +9,15 @@ #include "pool.h" #include "strmap.h" +#include "buffer.h" + +#define GIT_ATTR_CONFIG "core.attributesfile" +#define GIT_IGNORE_CONFIG "core.excludesfile" typedef struct { char *cfg_attr_file; /* cached value of core.attributesfile */ char *cfg_excl_file; /* cached value of core.excludesfile */ - git_strmap *files; /* hash path to git_attr_file of rules */ + git_strmap *files; /* hash path to git_attr_cache_entry records */ git_strmap *macros; /* hash name to vector<git_attr_assignment> */ git_mutex lock; git_pool pool; @@ -21,4 +25,53 @@ typedef struct { extern int git_attr_cache__init(git_repository *repo); +typedef enum { + GIT_ATTR_CACHE__FROM_FILE = 0, + GIT_ATTR_CACHE__FROM_INDEX = 1, + + GIT_ATTR_CACHE_NUM_SOURCES = 2 +} git_attr_cache_source; + +typedef struct git_attr_file git_attr_file; +typedef struct git_attr_rule git_attr_rule; + +typedef struct { + git_attr_file *file[GIT_ATTR_CACHE_NUM_SOURCES]; + const char *path; /* points into fullpath */ + char fullpath[GIT_FLEX_ARRAY]; +} git_attr_cache_entry; + +typedef int (*git_attr_cache_parser)( + git_repository *repo, + git_attr_file *file, + const char *data, + void *payload); + +/* get file - loading and reload as needed */ +extern int git_attr_cache__get( + git_attr_file **file, + git_repository *repo, + git_attr_cache_source source, + const char *base, + const char *filename, + git_attr_cache_parser parser, + void *payload); + +extern bool git_attr_cache__is_cached( + git_repository *repo, + git_attr_cache_source source, + const char *path); + +extern int git_attr_cache__insert_macro( + git_repository *repo, git_attr_rule *macro); + +extern git_attr_rule *git_attr_cache__lookup_macro( + git_repository *repo, const char *name); + +extern int git_attr_cache_entry__new( + git_attr_cache_entry **out, + const char *base, + const char *path, + git_pool *pool); + #endif |