Skip to content

Commit ec4d77a

Browse files
committed
attr.c: tighten constness around "git_attr" structure
It holds an interned string, and git_attr_name() is a way to peek into it. Make sure the involved pointer types are pointer-to-const. Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4b0c696 commit ec4d77a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int cannot_trust_maybe_real;
4343
static struct git_attr_check *check_all_attr;
4444
static struct git_attr *(git_attr_hash[HASHSIZE]);
4545

46-
char *git_attr_name(struct git_attr *attr)
46+
const char *git_attr_name(const struct git_attr *attr)
4747
{
4848
return attr->name;
4949
}

attr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern const char git_attr__false[];
2525
* Unset one is returned as NULL.
2626
*/
2727
struct git_attr_check {
28-
struct git_attr *attr;
28+
const struct git_attr *attr;
2929
const char *value;
3030
};
3131

@@ -34,7 +34,7 @@ struct git_attr_check {
3434
* return value is a pointer to a null-delimited string that is part
3535
* of the internal data structure; it should not be modified or freed.
3636
*/
37-
char *git_attr_name(struct git_attr *);
37+
extern const char *git_attr_name(const struct git_attr *);
3838

3939
int git_check_attr(const char *path, int, struct git_attr_check *);
4040

0 commit comments

Comments
 (0)