attr: eliminate global check_all_attr array
[alt-git.git] / attr.h
blob5aaf55c3e37bf2975a50c5774ebf42a736359a17
1 #ifndef ATTR_H
2 #define ATTR_H
4 /* An attribute is a pointer to this opaque structure */
5 struct git_attr;
7 /* opaque structure used internally for attribute collection */
8 struct all_attrs_item;
11 * Given a string, return the gitattribute object that
12 * corresponds to it.
14 struct git_attr *git_attr(const char *);
16 /* Internal use */
17 extern const char git_attr__true[];
18 extern const char git_attr__false[];
20 /* For public to check git_attr_check results */
21 #define ATTR_TRUE(v) ((v) == git_attr__true)
22 #define ATTR_FALSE(v) ((v) == git_attr__false)
23 #define ATTR_UNSET(v) ((v) == NULL)
26 * Send one or more git_attr_check to git_check_attrs(), and
27 * each 'value' member tells what its value is.
28 * Unset one is returned as NULL.
30 struct attr_check_item {
31 const struct git_attr *attr;
32 const char *value;
35 struct attr_check {
36 int nr;
37 int alloc;
38 struct attr_check_item *items;
39 int all_attrs_nr;
40 struct all_attrs_item *all_attrs;
43 extern struct attr_check *attr_check_alloc(void);
44 extern struct attr_check *attr_check_initl(const char *, ...);
46 extern struct attr_check_item *attr_check_append(struct attr_check *check,
47 const struct git_attr *attr);
49 extern void attr_check_reset(struct attr_check *check);
50 extern void attr_check_clear(struct attr_check *check);
51 extern void attr_check_free(struct attr_check *check);
54 * Return the name of the attribute represented by the argument. The
55 * return value is a pointer to a null-delimited string that is part
56 * of the internal data structure; it should not be modified or freed.
58 extern const char *git_attr_name(const struct git_attr *);
60 extern int git_check_attr(const char *path, struct attr_check *check);
63 * Retrieve all attributes that apply to the specified path.
64 * check holds the attributes and their values.
66 extern void git_all_attrs(const char *path, struct attr_check *check);
68 enum git_attr_direction {
69 GIT_ATTR_CHECKIN,
70 GIT_ATTR_CHECKOUT,
71 GIT_ATTR_INDEX
73 void git_attr_set_direction(enum git_attr_direction, struct index_state *);
75 extern void attr_start(void);
77 #endif /* ATTR_H */