Skip to content

Commit 352404a

Browse files
mhaggergitster
authored andcommitted
Provide access to the name attribute of git_attr
It will be present in any likely future reimplementation, and its availability simplifies other code. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 09d7dd7 commit 352404a

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Documentation/technical/api-gitattributes.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Data Structure
1313
An attribute is an opaque object that is identified by its name.
1414
Pass the name to `git_attr()` function to obtain the object of
1515
this type. The internal representation of this structure is
16-
of no interest to the calling programs.
16+
of no interest to the calling programs. The name of the
17+
attribute can be retrieved by calling `git_attr_name()`.
1718

1819
`struct git_attr_check`::
1920

attr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ static int attr_nr;
3636
static struct git_attr_check *check_all_attr;
3737
static struct git_attr *(git_attr_hash[HASHSIZE]);
3838

39+
char *git_attr_name(struct git_attr *attr)
40+
{
41+
return attr->name;
42+
}
43+
3944
static unsigned hash_name(const char *name, int namelen)
4045
{
4146
unsigned val = 0, c;

attr.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ struct git_attr_check {
2929
const char *value;
3030
};
3131

32+
/*
33+
* Return the name of the attribute represented by the argument. The
34+
* return value is a pointer to a null-delimited string that is part
35+
* of the internal data structure; it should not be modified or freed.
36+
*/
37+
char *git_attr_name(struct git_attr *);
38+
3239
int git_checkattr(const char *path, int, struct git_attr_check *);
3340

3441
enum git_attr_direction {

0 commit comments

Comments
 (0)