Code

git-remote-mediawiki: trivial fixes
[git.git] / attr.c
diff --git a/attr.c b/attr.c
index b8ce1586c89781194e07d37b1876de6be2de7329..da29c8eb452af6a0a07829ab1ed2409c8aea5ef2 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -565,8 +565,7 @@ static void prepare_attr_stack(const char *path)
         * .gitattributes in deeper directories to shallower ones,
         * and finally use the built-in set as the default.
         */
-       if (!attr_stack)
-               bootstrap_attr_stack();
+       bootstrap_attr_stack();
 
        /*
         * Pop the "info" one that is always at the top of the stack.
@@ -732,7 +731,7 @@ static void collect_all_attrs(const char *path)
                rem = fill(path, pathlen, stk, rem);
 }
 
-int git_checkattr(const char *path, int num, struct git_attr_check *check)
+int git_check_attr(const char *path, int num, struct git_attr_check *check)
 {
        int i;
 
@@ -748,6 +747,34 @@ int git_checkattr(const char *path, int num, struct git_attr_check *check)
        return 0;
 }
 
+int git_all_attrs(const char *path, int *num, struct git_attr_check **check)
+{
+       int i, count, j;
+
+       collect_all_attrs(path);
+
+       /* Count the number of attributes that are set. */
+       count = 0;
+       for (i = 0; i < attr_nr; i++) {
+               const char *value = check_all_attr[i].value;
+               if (value != ATTR__UNSET && value != ATTR__UNKNOWN)
+                       ++count;
+       }
+       *num = count;
+       *check = xmalloc(sizeof(**check) * count);
+       j = 0;
+       for (i = 0; i < attr_nr; i++) {
+               const char *value = check_all_attr[i].value;
+               if (value != ATTR__UNSET && value != ATTR__UNKNOWN) {
+                       (*check)[j].attr = check_all_attr[i].attr;
+                       (*check)[j].value = value;
+                       ++j;
+               }
+       }
+
+       return 0;
+}
+
 void git_attr_set_direction(enum git_attr_direction new, struct index_state *istate)
 {
        enum git_attr_direction old = direction;