@@ -30,7 +30,7 @@ GIT_BEGIN_DECL
3030 * Then for file `xyz.c` looking up attribute "foo" gives a value for
3131 * which `GIT_ATTR_TRUE(value)` is true.
3232 */
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 )
3434
3535/**
3636 * GIT_ATTR_FALSE checks if an attribute is set off. In core git
@@ -44,7 +44,7 @@ GIT_BEGIN_DECL
4444 * Then for file `zyx.h` looking up attribute "foo" gives a value for
4545 * which `GIT_ATTR_FALSE(value)` is true.
4646 */
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 )
4848
4949/**
5050 * GIT_ATTR_UNSPECIFIED checks if an attribute is unspecified. This
@@ -62,7 +62,7 @@ GIT_BEGIN_DECL
6262 * file `onefile.rb` or looking up "bar" on any file will all give
6363 * `GIT_ATTR_UNSPECIFIED(value)` of true.
6464 */
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 )
6666
6767/**
6868 * GIT_ATTR_HAS_VALUE checks if an attribute is set to a value (as
@@ -74,17 +74,17 @@ GIT_BEGIN_DECL
7474 * Given this, looking up "eol" for `onefile.txt` will give back the
7575 * string "lf" and `GIT_ATTR_SET_TO_VALUE(attr)` will return true.
7676 */
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 )
7878
7979/**
8080 * Possible states for an attribute
8181 */
8282typedef 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 ;
8888
8989/**
9090 * Return the value type for a given attribute.
@@ -99,7 +99,7 @@ typedef enum {
9999 * @param attr The attribute
100100 * @return the value type for the attribute
101101 */
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 );
103103
104104/**
105105 * 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);
119119#define GIT_ATTR_CHECK_INDEX_ONLY 2
120120
121121/**
122- * Check attribute flags: Using the system attributes file .
122+ * Check attribute flags: controlling extended attribute behavior .
123123 *
124124 * Normally, attribute checks include looking in the /etc (or system
125125 * equivalent) directory for a `gitattributes` file. Passing this
126126 * 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.
127133 */
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)
129136
130137/**
131138 * Look up the value of one git attribute for path.
@@ -186,7 +193,23 @@ GIT_EXTERN(int) git_attr_get_many(
186193 size_t num_attr ,
187194 const char * * names );
188195
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 );
190213
191214/**
192215 * 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
196219 * @param path Path inside the repo to check attributes. This does not have
197220 * to exist, but if it does not, then it will be treated as a
198221 * 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.
206224 * @param payload Passed on as extra parameter to callback function.
207225 * @return 0 on success, non-zero callback return value, or error code
208226 */
@@ -220,8 +238,11 @@ GIT_EXTERN(int) git_attr_foreach(
220238 * disk no longer match the cached contents of memory. This will cause
221239 * the attributes files to be reloaded the next time that an attribute
222240 * access function is called.
241+ *
242+ * @param repo The repository containing the gitattributes cache
243+ * @return 0 on success, or an error code
223244 */
224- GIT_EXTERN (void ) git_attr_cache_flush (
245+ GIT_EXTERN (int ) git_attr_cache_flush (
225246 git_repository * repo );
226247
227248/**
0 commit comments