]> git.ipfire.org Git - thirdparty/git.git/blame - attr.h
attr: tighten const correctness with git_attr and match_attr
[thirdparty/git.git] / attr.h
CommitLineData
d0bfd026
JH
1#ifndef ATTR_H
2#define ATTR_H
3
4/* An attribute is a pointer to this opaque structure */
5struct git_attr;
6
685b2925
BW
7/* opaque structure used internally for attribute collection */
8struct all_attrs_item;
9
a5e92abd
JH
10/*
11 * Given a string, return the gitattribute object that
12 * corresponds to it.
13 */
e810e063 14const struct git_attr *git_attr(const char *);
d0bfd026 15
515106fa 16/* Internal use */
a5e92abd
JH
17extern const char git_attr__true[];
18extern const char git_attr__false[];
515106fa
JH
19
20/* For public to check git_attr_check results */
a5e92abd
JH
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)
515106fa 24
a5e92abd 25/*
7bd18054 26 * Send one or more git_attr_check to git_check_attrs(), and
a5e92abd
JH
27 * each 'value' member tells what its value is.
28 * Unset one is returned as NULL.
29 */
7bd18054 30struct attr_check_item {
ec4d77aa 31 const struct git_attr *attr;
a5e92abd 32 const char *value;
d0bfd026
JH
33};
34
37293768
JH
35struct attr_check {
36 int nr;
37 int alloc;
38 struct attr_check_item *items;
685b2925
BW
39 int all_attrs_nr;
40 struct all_attrs_item *all_attrs;
37293768
JH
41};
42
43extern struct attr_check *attr_check_alloc(void);
44extern struct attr_check *attr_check_initl(const char *, ...);
45
46extern struct attr_check_item *attr_check_append(struct attr_check *check,
47 const struct git_attr *attr);
48
49extern void attr_check_reset(struct attr_check *check);
50extern void attr_check_clear(struct attr_check *check);
51extern void attr_check_free(struct attr_check *check);
52
352404ac
MH
53/*
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.
57 */
ec4d77aa 58extern const char *git_attr_name(const struct git_attr *);
352404ac 59
37293768 60extern int git_check_attr(const char *path, struct attr_check *check);
d0bfd026 61
ee548df3 62/*
7f864111
JH
63 * Retrieve all attributes that apply to the specified path.
64 * check holds the attributes and their values.
ee548df3 65 */
7f864111 66extern void git_all_attrs(const char *path, struct attr_check *check);
ee548df3 67
06f33c17
JH
68enum git_attr_direction {
69 GIT_ATTR_CHECKIN,
4191e80a 70 GIT_ATTR_CHECKOUT,
4b05548f 71 GIT_ATTR_INDEX
06f33c17
JH
72};
73void git_attr_set_direction(enum git_attr_direction, struct index_state *);
74
1a600b75
BW
75extern void attr_start(void);
76
d0bfd026 77#endif /* ATTR_H */