diff options
author | Russell Belfer <rb@github.com> | 2014-04-10 22:31:01 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-04-17 14:56:41 -0700 |
commit | 7d4908724fd7d4d8e096b4faf2c652ba5b77644e (patch) | |
tree | 2fcd09e7e040607c124f6e658c31f33e1aa1868a /src/attrcache.h | |
parent | 1fa17b5c92cb92a2785fba403b87525169b205c0 (diff) | |
download | libgit2-7d4908724fd7d4d8e096b4faf2c652ba5b77644e.tar.gz |
Attribute file cache refactor
This is a big refactoring of the attribute file cache to be a bit
simpler which in turn makes it easier to enforce a lock around any
updates to the cache so that it can be used in a threaded env.
Tons of changes to the attributes and ignores code.
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 |