Code

git-svn: test for creating new directories over svn://
[git.git] / attr.c
diff --git a/attr.c b/attr.c
index b3496a6eb529c111ff0378a517b13ca89cb74d5a..a0712543b2076a90f38d36c5ed0e8efa2639e316 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -1,7 +1,13 @@
 #include "cache.h"
 #include "attr.h"
 
-#define ATTR__UNKNOWN  ((void *) -2)
+const char git_attr__true[] = "(builtin)true";
+const char git_attr__false[] = "\0(builtin)false";
+static const char git_attr__unknown[] = "(builtin)unknown";
+#define ATTR__TRUE git_attr__true
+#define ATTR__FALSE git_attr__false
+#define ATTR__UNSET NULL
+#define ATTR__UNKNOWN git_attr__unknown
 
 /*
  * The basic design decision here is that we are not going to have
@@ -102,7 +108,7 @@ struct git_attr *git_attr(const char *name, int len)
 /* What does a matched pattern decide? */
 struct attr_state {
        struct git_attr *attr;
-       void *setto;
+       const char *setto;
 };
 
 struct match_attr {
@@ -262,14 +268,14 @@ static void free_attr_elem(struct attr_stack *e)
                struct match_attr *a = e->attrs[i];
                int j;
                for (j = 0; j < a->num_attr; j++) {
-                       void *setto = a->state[j].setto;
+                       const char *setto = a->state[j].setto;
                        if (setto == ATTR__TRUE ||
                            setto == ATTR__FALSE ||
                            setto == ATTR__UNSET ||
                            setto == ATTR__UNKNOWN)
                                ;
                        else
-                               free(setto);
+                               free((char*) setto);
                }
                free(a);
        }
@@ -294,7 +300,8 @@ static struct attr_stack *read_attr_from_array(const char **list)
                a = parse_attr_line(line, "[builtin]", ++lineno, 1);
                if (!a)
                        continue;
-               res->attrs = xrealloc(res->attrs, res->num_matches + 1);
+               res->attrs = xrealloc(res->attrs,
+                       sizeof(struct match_attr *) * (res->num_matches + 1));
                res->attrs[res->num_matches++] = a;
        }
        return res;
@@ -318,7 +325,8 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
                a = parse_attr_line(buf, path, ++lineno, macro_ok);
                if (!a)
                        continue;
-               res->attrs = xrealloc(res->attrs, res->num_matches + 1);
+               res->attrs = xrealloc(res->attrs,
+                       sizeof(struct match_attr *) * (res->num_matches + 1));
                res->attrs[res->num_matches++] = a;
        }
        fclose(fp);
@@ -478,8 +486,8 @@ static int fill_one(const char *what, struct match_attr *a, int rem)
 
        for (i = 0; 0 < rem && i < a->num_attr; i++) {
                struct git_attr *attr = a->state[i].attr;
-               void **n = &(check[attr->attr_nr].value);
-               void *v = a->state[i].setto;
+               const char **n = &(check[attr->attr_nr].value);
+               const char *v = a->state[i].setto;
 
                if (*n == ATTR__UNKNOWN) {
                        debug_set(what, a->u.pattern, attr, v);
@@ -547,7 +555,7 @@ int git_checkattr(const char *path, int num, struct git_attr_check *check)
                rem = macroexpand(stk, rem);
 
        for (i = 0; i < num; i++) {
-               void *value = check_all_attr[check[i].attr->attr_nr].value;
+               const char *value = check_all_attr[check[i].attr->attr_nr].value;
                if (value == ATTR__UNKNOWN)
                        value = ATTR__UNSET;
                check[i].value = value;