Merge branch 'cw/rebase-i-root'
[gitweb.git] / attr.c
diff --git a/attr.c b/attr.c
index 96eda0ef078f998c020666f89eea29ac4b1bfb53..aef93d896f7e72ec534c0c2c576e418bedc5cb30 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -301,6 +301,7 @@ static void free_attr_elem(struct attr_stack *e)
                }
                free(a);
        }
+       free(e->attrs);
        free(e);
 }
 
@@ -496,6 +497,7 @@ static int git_attr_system(void)
 static void bootstrap_attr_stack(void)
 {
        struct attr_stack *elem;
+       char *xdg_attributes_file;
 
        if (attr_stack)
                return;
@@ -514,13 +516,15 @@ static void bootstrap_attr_stack(void)
                }
        }
 
-       if (git_attributes_file) {
-               elem = read_attr_from_file(git_attributes_file, 1);
-               if (elem) {
-                       elem->origin = NULL;
-                       elem->prev = attr_stack;
-                       attr_stack = elem;
-               }
+       if (!git_attributes_file) {
+               home_config_paths(NULL, &xdg_attributes_file, "attributes");
+               git_attributes_file = xdg_attributes_file;
+       }
+       elem = read_attr_from_file(git_attributes_file, 1);
+       if (elem) {
+               elem->origin = NULL;
+               elem->prev = attr_stack;
+               attr_stack = elem;
        }
 
        if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {