diff options
Diffstat (limited to 'src/attr_file.h')
-rw-r--r-- | src/attr_file.h | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/src/attr_file.h b/src/attr_file.h index dbd6696c9..f92ce3c96 100644 --- a/src/attr_file.h +++ b/src/attr_file.h @@ -13,6 +13,7 @@ #include "pool.h" #include "buffer.h" #include "fileops.h" +#include "attrcache.h" #define GIT_ATTR_FILE ".gitattributes" #define GIT_ATTR_FILE_INREPO "info/attributes" @@ -45,10 +46,10 @@ typedef struct { unsigned int flags; } git_attr_fnmatch; -typedef struct { +struct git_attr_rule { git_attr_fnmatch match; git_vector assigns; /* vector of <git_attr_assignment*> */ -} git_attr_rule; +}; typedef struct { git_refcount unused; @@ -63,17 +64,17 @@ typedef struct { const char *value; } git_attr_assignment; -typedef struct { +struct git_attr_file { git_refcount rc; - char *key; /* cache "source#path" this was loaded from */ - git_vector rules; /* vector of <rule*> or <fnmatch*> */ - git_pool *pool; - bool pool_is_allocated; + git_attr_cache_entry *ce; + git_attr_cache_source source; + git_vector rules; /* vector of <rule*> or <fnmatch*> */ + git_pool pool; union { git_oid oid; git_futils_filestamp stamp; } cache_data; -} git_attr_file; +}; typedef struct { git_buf full; @@ -82,29 +83,41 @@ typedef struct { int is_dir; } git_attr_path; -typedef enum { - GIT_ATTR_FILE_FROM_FILE = 0, - GIT_ATTR_FILE_FROM_INDEX = 1 -} git_attr_file_source; - /* * git_attr_file API */ -extern int git_attr_file__new( - git_attr_file **attrs_ptr, git_attr_file_source src, const char *path, git_pool *pool); +int git_attr_file__new( + git_attr_file **out, + git_attr_cache_entry *ce, + git_attr_cache_source source); + +void git_attr_file__free(git_attr_file *file); + +int git_attr_file__load( + git_attr_file **out, + git_repository *repo, + git_attr_cache_entry *ce, + git_attr_cache_source source, + git_attr_cache_parser parser, + void *payload); -extern int git_attr_file__new_and_load( - git_attr_file **attrs_ptr, const char *path); +int git_attr_file__load_standalone( + git_attr_file **out, + const char *path); -extern void git_attr_file__free(git_attr_file *file); +int git_attr_file__out_of_date( + git_repository *repo, git_attr_file *file); -extern void git_attr_file__clear_rules(git_attr_file *file); +int git_attr_file__parse_buffer( + git_repository *repo, + git_attr_file *attrs, + const char *data, + void *payload); -extern int git_attr_file__parse_buffer( - git_repository *repo, void *parsedata, const char *buf, git_attr_file *file); +void git_attr_file__clear_rules(git_attr_file *file); -extern int git_attr_file__lookup_one( +int git_attr_file__lookup_one( git_attr_file *file, const git_attr_path *path, const char *attr, @@ -115,7 +128,7 @@ extern int git_attr_file__lookup_one( git_vector_rforeach(&(file)->rules, (iter), (rule)) \ if (git_attr_rule__match((rule), (path))) -extern uint32_t git_attr_file__name_hash(const char *name); +uint32_t git_attr_file__name_hash(const char *name); /* |