attr: tighten const correctness with git_attr and match_attr
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
60a12722ac
commit
e810e06357
12
attr.c
12
attr.c
@ -220,7 +220,7 @@ static void report_invalid_attr(const char *name, size_t len,
|
||||
* dictionary. If no entry is found, create a new attribute and store it in
|
||||
* the dictionary.
|
||||
*/
|
||||
static struct git_attr *git_attr_internal(const char *name, int namelen)
|
||||
static const struct git_attr *git_attr_internal(const char *name, int namelen)
|
||||
{
|
||||
struct git_attr *a;
|
||||
|
||||
@ -244,14 +244,14 @@ static struct git_attr *git_attr_internal(const char *name, int namelen)
|
||||
return a;
|
||||
}
|
||||
|
||||
struct git_attr *git_attr(const char *name)
|
||||
const struct git_attr *git_attr(const char *name)
|
||||
{
|
||||
return git_attr_internal(name, strlen(name));
|
||||
}
|
||||
|
||||
/* What does a matched pattern decide? */
|
||||
struct attr_state {
|
||||
struct git_attr *attr;
|
||||
const struct git_attr *attr;
|
||||
const char *setto;
|
||||
};
|
||||
|
||||
@ -278,7 +278,7 @@ struct pattern {
|
||||
struct match_attr {
|
||||
union {
|
||||
struct pattern pat;
|
||||
struct git_attr *attr;
|
||||
const struct git_attr *attr;
|
||||
} u;
|
||||
char is_macro;
|
||||
unsigned num_attr;
|
||||
@ -898,7 +898,7 @@ static int fill_one(const char *what, struct all_attrs_item *all_attrs,
|
||||
int i;
|
||||
|
||||
for (i = a->num_attr - 1; rem > 0 && i >= 0; i--) {
|
||||
struct git_attr *attr = a->state[i].attr;
|
||||
const struct git_attr *attr = a->state[i].attr;
|
||||
const char **n = &(all_attrs[attr->attr_nr].value);
|
||||
const char *v = a->state[i].setto;
|
||||
|
||||
@ -922,7 +922,7 @@ static int fill(const char *path, int pathlen, int basename_offset,
|
||||
const char *base = stk->origin ? stk->origin : "";
|
||||
|
||||
for (i = stk->num_matches - 1; 0 < rem && 0 <= i; i--) {
|
||||
struct match_attr *a = stk->attrs[i];
|
||||
const struct match_attr *a = stk->attrs[i];
|
||||
if (a->is_macro)
|
||||
continue;
|
||||
if (path_matches(path, pathlen, basename_offset,
|
||||
|
Reference in New Issue
Block a user