@@ -30,7 +30,7 @@ GIT_BEGIN_DECL
30
30
* Then for file `xyz.c` looking up attribute "foo" gives a value for
31
31
* which `GIT_ATTR_TRUE(value)` is true.
32
32
*/
33
- #define GIT_ATTR_TRUE (attr ) (git_attr_value(attr) == GIT_ATTR_TRUE_T )
33
+ #define GIT_ATTR_IS_TRUE (attr ) (git_attr_value(attr) == GIT_ATTR_VALUE_TRUE )
34
34
35
35
/**
36
36
* GIT_ATTR_FALSE checks if an attribute is set off. In core git
@@ -44,7 +44,7 @@ GIT_BEGIN_DECL
44
44
* Then for file `zyx.h` looking up attribute "foo" gives a value for
45
45
* which `GIT_ATTR_FALSE(value)` is true.
46
46
*/
47
- #define GIT_ATTR_FALSE (attr ) (git_attr_value(attr) == GIT_ATTR_FALSE_T )
47
+ #define GIT_ATTR_IS_FALSE (attr ) (git_attr_value(attr) == GIT_ATTR_VALUE_FALSE )
48
48
49
49
/**
50
50
* GIT_ATTR_UNSPECIFIED checks if an attribute is unspecified. This
@@ -62,7 +62,7 @@ GIT_BEGIN_DECL
62
62
* file `onefile.rb` or looking up "bar" on any file will all give
63
63
* `GIT_ATTR_UNSPECIFIED(value)` of true.
64
64
*/
65
- #define GIT_ATTR_UNSPECIFIED (attr ) (git_attr_value(attr) == GIT_ATTR_UNSPECIFIED_T )
65
+ #define GIT_ATTR_IS_UNSPECIFIED (attr ) (git_attr_value(attr) == GIT_ATTR_VALUE_UNSPECIFIED )
66
66
67
67
/**
68
68
* GIT_ATTR_HAS_VALUE checks if an attribute is set to a value (as
@@ -74,17 +74,17 @@ GIT_BEGIN_DECL
74
74
* Given this, looking up "eol" for `onefile.txt` will give back the
75
75
* string "lf" and `GIT_ATTR_SET_TO_VALUE(attr)` will return true.
76
76
*/
77
- #define GIT_ATTR_HAS_VALUE (attr ) (git_attr_value(attr) == GIT_ATTR_VALUE_T )
77
+ #define GIT_ATTR_HAS_VALUE (attr ) (git_attr_value(attr) == GIT_ATTR_VALUE_STRING )
78
78
79
79
/**
80
80
* Possible states for an attribute
81
81
*/
82
82
typedef enum {
83
- GIT_ATTR_UNSPECIFIED_T = 0 , /**< The attribute has been left unspecified */
84
- GIT_ATTR_TRUE_T , /**< The attribute has been set */
85
- GIT_ATTR_FALSE_T , /**< The attribute has been unset */
86
- GIT_ATTR_VALUE_T , /**< This attribute has a value */
87
- } git_attr_t ;
83
+ GIT_ATTR_VALUE_UNSPECIFIED = 0 , /**< The attribute has been left unspecified */
84
+ GIT_ATTR_VALUE_TRUE , /**< The attribute has been set */
85
+ GIT_ATTR_VALUE_FALSE , /**< The attribute has been unset */
86
+ GIT_ATTR_VALUE_STRING , /**< This attribute has a value */
87
+ } git_attr_value_t ;
88
88
89
89
/**
90
90
* Return the value type for a given attribute.
@@ -99,7 +99,7 @@ typedef enum {
99
99
* @param attr The attribute
100
100
* @return the value type for the attribute
101
101
*/
102
- GIT_EXTERN (git_attr_t ) git_attr_value (const char * attr );
102
+ GIT_EXTERN (git_attr_value_t ) git_attr_value (const char * attr );
103
103
104
104
/**
105
105
* Check attribute flags: Reading values from index and working directory.
@@ -119,13 +119,20 @@ GIT_EXTERN(git_attr_t) git_attr_value(const char *attr);
119
119
#define GIT_ATTR_CHECK_INDEX_ONLY 2
120
120
121
121
/**
122
- * Check attribute flags: Using the system attributes file .
122
+ * Check attribute flags: controlling extended attribute behavior .
123
123
*
124
124
* Normally, attribute checks include looking in the /etc (or system
125
125
* equivalent) directory for a `gitattributes` file. Passing this
126
126
* flag will cause attribute checks to ignore that file.
127
+ * equivalent) directory for a `gitattributes` file. Passing the
128
+ * `GIT_ATTR_CHECK_NO_SYSTEM` flag will cause attribute checks to
129
+ * ignore that file.
130
+ *
131
+ * Passing the `GIT_ATTR_CHECK_INCLUDE_HEAD` flag will use attributes
132
+ * from a `.gitattributes` file in the repository at the HEAD revision.
127
133
*/
128
- #define GIT_ATTR_CHECK_NO_SYSTEM (1 << 2)
134
+ #define GIT_ATTR_CHECK_NO_SYSTEM (1 << 2)
135
+ #define GIT_ATTR_CHECK_INCLUDE_HEAD (1 << 3)
129
136
130
137
/**
131
138
* Look up the value of one git attribute for path.
@@ -186,7 +193,23 @@ GIT_EXTERN(int) git_attr_get_many(
186
193
size_t num_attr ,
187
194
const char * * names );
188
195
189
- typedef int (* git_attr_foreach_cb )(const char * name , const char * value , void * payload );
196
+ /**
197
+ * The callback used with git_attr_foreach.
198
+ *
199
+ * This callback will be invoked only once per attribute name, even if there
200
+ * are multiple rules for a given file. The highest priority rule will be
201
+ * used.
202
+ *
203
+ * @see git_attr_foreach.
204
+ *
205
+ * @param name The attribute name.
206
+ * @param value The attribute value. May be NULL if the attribute is explicitly
207
+ * set to UNSPECIFIED using the '!' sign.
208
+ * @param payload A user-specified pointer.
209
+ * @return 0 to continue looping, non-zero to stop. This value will be returned
210
+ * from git_attr_foreach.
211
+ */
212
+ typedef int GIT_CALLBACK (git_attr_foreach_cb )(const char * name , const char * value , void * payload );
190
213
191
214
/**
192
215
* Loop over all the git attributes for a path.
@@ -196,13 +219,8 @@ typedef int (*git_attr_foreach_cb)(const char *name, const char *value, void *pa
196
219
* @param path Path inside the repo to check attributes. This does not have
197
220
* to exist, but if it does not, then it will be treated as a
198
221
* plain file (i.e. not a directory).
199
- * @param callback Function to invoke on each attribute name and value. The
200
- * value may be NULL is the attribute is explicitly set to
201
- * UNSPECIFIED using the '!' sign. Callback will be invoked
202
- * only once per attribute name, even if there are multiple
203
- * rules for a given file. The highest priority rule will be
204
- * used. Return a non-zero value from this to stop looping.
205
- * The value will be returned from `git_attr_foreach`.
222
+ * @param callback Function to invoke on each attribute name and value.
223
+ * See git_attr_foreach_cb.
206
224
* @param payload Passed on as extra parameter to callback function.
207
225
* @return 0 on success, non-zero callback return value, or error code
208
226
*/
@@ -220,8 +238,11 @@ GIT_EXTERN(int) git_attr_foreach(
220
238
* disk no longer match the cached contents of memory. This will cause
221
239
* the attributes files to be reloaded the next time that an attribute
222
240
* access function is called.
241
+ *
242
+ * @param repo The repository containing the gitattributes cache
243
+ * @return 0 on success, or an error code
223
244
*/
224
- GIT_EXTERN (void ) git_attr_cache_flush (
245
+ GIT_EXTERN (int ) git_attr_cache_flush (
225
246
git_repository * repo );
226
247
227
248
/**
0 commit comments