use skip_prefix to avoid magic numbers
[gitweb.git] / attr.c
diff --git a/attr.c b/attr.c
index 243d60ffa9a6a097514ddfeb74c98ae7bb30f35c..734222dc45c588736f963dea7907258e76024415 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -211,7 +211,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
        name = cp;
        namelen = strcspn(name, blank);
        if (strlen(ATTRIBUTE_MACRO_PREFIX) < namelen &&
-           !prefixcmp(name, ATTRIBUTE_MACRO_PREFIX)) {
+           starts_with(name, ATTRIBUTE_MACRO_PREFIX)) {
                if (!macro_ok) {
                        fprintf(stderr, "%s not allowed: %s:%d\n",
                                name, src, lineno);
@@ -286,7 +286,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
  * (reading the file from top to bottom), .gitattribute of the root
  * directory (again, reading the file from top to bottom) down to the
  * current directory, and then scan the list backwards to find the first match.
- * This is exactly the same as what excluded() does in dir.c to deal with
+ * This is exactly the same as what is_excluded() does in dir.c to deal with
  * .gitignore
  */
 
@@ -338,12 +338,7 @@ static void handle_attr_line(struct attr_stack *res,
        a = parse_attr_line(line, src, lineno, macro_ok);
        if (!a)
                return;
-       if (res->alloc <= res->num_matches) {
-               res->alloc = alloc_nr(res->num_matches);
-               res->attrs = xrealloc(res->attrs,
-                                     sizeof(struct match_attr *) *
-                                     res->alloc);
-       }
+       ALLOC_GROW(res->attrs, res->num_matches + 1, res->alloc);
        res->attrs[res->num_matches++] = a;
 }
 
@@ -387,7 +382,7 @@ static struct attr_stack *read_attr_from_index(const char *path, int macro_ok)
        char *buf, *sp;
        int lineno = 0;
 
-       buf = read_blob_data_from_index(use_index ? use_index : &the_index, path);
+       buf = read_blob_data_from_index(use_index ? use_index : &the_index, path, NULL);
        if (!buf)
                return NULL;