Allow querying all attributes on a file

Add a function, git_all_attrs(), that reports on all attributes that
are set on a path.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty
2011-08-04 06:36:23 +02:00
committed by Junio C Hamano
parent 7373eab48e
commit ee548df300
3 changed files with 67 additions and 14 deletions

View File

@ -22,19 +22,6 @@ Data Structure
to `git_checkattr()` function, and receives the results.
Calling Sequence
----------------
* Prepare an array of `struct git_attr_check` to define the list of
attributes you would want to check. To populate this array, you would
need to define necessary attributes by calling `git_attr()` function.
* Call git_checkattr() to check the attributes for the path.
* Inspect `git_attr_check` structure to see how each of the attribute in
the array is defined for the path.
Attribute Values
----------------
@ -58,6 +45,19 @@ If none of the above returns true, `.value` member points at a string
value of the attribute for the path.
Querying Specific Attributes
----------------------------
* Prepare an array of `struct git_attr_check` to define the list of
attributes you would want to check. To populate this array, you would
need to define necessary attributes by calling `git_attr()` function.
* Call `git_checkattr()` to check the attributes for the path.
* Inspect `git_attr_check` structure to see how each of the attribute in
the array is defined for the path.
Example
-------
@ -109,4 +109,20 @@ static void setup_check(void)
}
------------
(JC)
Querying All Attributes
-----------------------
To get the values of all attributes associated with a file:
* Call `git_all_attrs()`, which returns an array of `git_attr_check`
structures.
* Iterate over the `git_attr_check` array to examine the attribute
names and values. The name of the attribute described by a
`git_attr_check` object can be retrieved via
`git_attr_name(check[i].attr)`. (Please note that no items will be
returned for unset attributes, so `ATTR_UNSET()` will return false
for all returned `git_array_check` objects.)
* Free the `git_array_check` array.