summaryrefslogtreecommitdiff
path: root/src/attr_file.h
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-01-09 15:37:19 -0800
committerRussell Belfer <arrbee@arrbee.com>2012-01-11 14:39:51 -0800
commitdf743c7d3a04553ffc04ae7cbc64fb300e7f61d2 (patch)
tree7f0dfa714ddb292448cbeaa69f2b5d90a3274d85 /src/attr_file.h
parent7e443f696068cd8c84a759e532c2845348e5a6ad (diff)
downloadlibgit2-df743c7d3a04553ffc04ae7cbc64fb300e7f61d2.tar.gz
Initial implementation of gitignore support
Adds support for .gitignore files to git_status_foreach() and git_status_file(). This includes refactoring the gitattributes code to share logic where possible. The GIT_STATUS_IGNORED flag will now be passed in for files that are ignored (provided they are not already in the index or the head of repo).
Diffstat (limited to 'src/attr_file.h')
-rw-r--r--src/attr_file.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/attr_file.h b/src/attr_file.h
index bed440d61..86836b56f 100644
--- a/src/attr_file.h
+++ b/src/attr_file.h
@@ -15,6 +15,7 @@
#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 +24,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 +43,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 +53,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 +62,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 +74,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 +83,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 +108,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