diff options
| author | Russell Belfer <arrbee@arrbee.com> | 2012-01-16 15:34:35 -0800 |
|---|---|---|
| committer | Russell Belfer <arrbee@arrbee.com> | 2012-01-16 15:34:35 -0800 |
| commit | 6e03b12f5715cb3f5cb5c8be6512e041cdf44a05 (patch) | |
| tree | 8da5a75da0e2013f34bac773fe201b2a989605f5 /src/attr_file.h | |
| parent | d9e5430e5a7bd5d2de7c4fee2f1afbd52ec5aa2f (diff) | |
| parent | cfbc880d8a407bcd2074dda4221d337daf72195c (diff) | |
| download | libgit2-6e03b12f5715cb3f5cb5c8be6512e041cdf44a05.tar.gz | |
Merge pull request #531 from arrbee/gitignore
Initial implementation of gitignore support
git_status_foreach() and git_status_file() will now be
gitignore aware.
Diffstat (limited to 'src/attr_file.h')
| -rw-r--r-- | src/attr_file.h | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/attr_file.h b/src/attr_file.h index bed440d61..7190c4c7b 100644 --- a/src/attr_file.h +++ b/src/attr_file.h @@ -11,10 +11,16 @@ #include "vector.h" #include "hashtable.h" +#define GIT_ATTR_FILE ".gitattributes" +#define GIT_ATTR_FILE_INREPO "info/attributes" +#define GIT_ATTR_FILE_SYSTEM "gitattributes" +#define GIT_ATTR_CONFIG "core.attributesfile" + #define GIT_ATTR_FNMATCH_NEGATIVE (1U << 0) #define GIT_ATTR_FNMATCH_DIRECTORY (1U << 1) #define GIT_ATTR_FNMATCH_FULLPATH (1U << 2) #define GIT_ATTR_FNMATCH_MACRO (1U << 3) +#define GIT_ATTR_FNMATCH_IGNORE (1U << 4) typedef struct { char *pattern; @@ -23,13 +29,18 @@ typedef struct { } git_attr_fnmatch; typedef struct { + git_attr_fnmatch match; + git_vector assigns; /* vector of <git_attr_assignment*> */ +} git_attr_rule; + +typedef struct { git_refcount unused; const char *name; unsigned long name_hash; } git_attr_name; typedef struct { - git_refcount rc; /* for macros */ + git_refcount rc; /* for macros */ char *name; unsigned long name_hash; const char *value; @@ -37,13 +48,8 @@ typedef struct { } git_attr_assignment; typedef struct { - git_attr_fnmatch match; - git_vector assigns; /* vector of <git_attr_assignment*> */ -} git_attr_rule; - -typedef struct { - char *path; /* cache the path this was loaded from */ - git_vector rules; /* vector of <git_attr_rule*> */ + char *path; /* cache the path this was loaded from */ + git_vector rules; /* vector of <rule*> or <fnmatch*> */ } git_attr_file; typedef struct { @@ -52,12 +58,6 @@ typedef struct { int is_dir; } git_attr_path; -typedef struct { - int initialized; - git_hashtable *files; /* hash path to git_attr_file */ - git_hashtable *macros; /* hash name to vector<git_attr_assignment> */ -} git_attr_cache; - /* * git_attr_file API */ @@ -67,6 +67,7 @@ extern int git_attr_file__from_buffer( extern int git_attr_file__from_file( git_repository *repo, const char *path, git_attr_file **out); +extern int git_attr_file__new(git_attr_file **attrs_ptr); extern void git_attr_file__free(git_attr_file *file); extern int git_attr_file__lookup_one( @@ -78,7 +79,7 @@ extern int git_attr_file__lookup_one( /* loop over rules in file from bottom to top */ #define git_attr_file__foreach_matching_rule(file, path, iter, rule) \ git_vector_rforeach(&(file)->rules, (iter), (rule)) \ - if (git_attr_rule__match_path((rule), (path)) == GIT_SUCCESS) + if (git_attr_rule__match((rule), (path)) == GIT_SUCCESS) extern unsigned long git_attr_file__name_hash(const char *name); @@ -87,9 +88,17 @@ extern unsigned long git_attr_file__name_hash(const char *name); * other utilities */ +extern int git_attr_fnmatch__parse( + git_attr_fnmatch *spec, + const char **base); + +extern int git_attr_fnmatch__match( + git_attr_fnmatch *rule, + const git_attr_path *path); + extern void git_attr_rule__free(git_attr_rule *rule); -extern int git_attr_rule__match_path( +extern int git_attr_rule__match( git_attr_rule *rule, const git_attr_path *path); @@ -104,7 +113,4 @@ extern int git_attr_assignment__parse( git_vector *assigns, const char **scan); -extern int git_attr_cache__insert_macro( - git_repository *repo, git_attr_rule *macro); - #endif |
