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>

Junio C Hamano committed Jan 27, 2017 at 18:01 UTC ec4d77aa508ac36f1f65ca8f228d4cbac42d694c
2 files changed +3 -3
attr.c
+1 -1
@@ -43,7 +43,7 @@ static int cannot_trust_maybe_real;
43 static struct git_attr_check *check_all_attr;
44 static struct git_attr *(git_attr_hash[HASHSIZE]);
45
46 -char *git_attr_name(struct git_attr *attr)
46 +const char *git_attr_name(const struct git_attr *attr)
47 {
48 return attr->name;
49 }
attr.h
+2 -2
@@ -25,7 +25,7 @@ extern const char git_attr__false[];
25 * Unset one is returned as NULL.
26 */
27 struct git_attr_check {
28 - struct git_attr *attr;
28 + const struct git_attr *attr;
29 const char *value;
30 };
31
@@ -34,7 +34,7 @@ struct git_attr_check {
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 *);
37 +extern const char *git_attr_name(const struct git_attr *);
38
39 int git_check_attr(const char *path, int, struct git_attr_check *);
40