Merge branch 'pw/rebase-i-regression-fix-tests'
[gitweb.git] / attr.c
diff --git a/attr.c b/attr.c
index 7e2134471cb4afc1b891208ebe4bebd6ad55571d..37454999d21e9dcea73e6717da608d80720235e8 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -9,6 +9,7 @@
 
 #define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
+#include "config.h"
 #include "exec_cmd.h"
 #include "attr.h"
 #include "dir.h"
@@ -638,13 +639,11 @@ void attr_check_reset(struct attr_check *check)
 
 void attr_check_clear(struct attr_check *check)
 {
-       free(check->items);
-       check->items = NULL;
+       FREE_AND_NULL(check->items);
        check->alloc = 0;
        check->nr = 0;
 
-       free(check->all_attrs);
-       check->all_attrs = NULL;
+       FREE_AND_NULL(check->all_attrs);
        check->all_attrs_nr = 0;
 
        drop_attr_stack(&check->stack);
@@ -720,16 +719,13 @@ void git_attr_set_direction(enum git_attr_direction new_direction,
 
 static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
 {
-       FILE *fp = fopen(path, "r");
+       FILE *fp = fopen_or_warn(path, "r");
        struct attr_stack *res;
        char buf[2048];
        int lineno = 0;
 
-       if (!fp) {
-               if (errno != ENOENT && errno != ENOTDIR)
-                       warn_on_inaccessible(path);
+       if (!fp)
                return NULL;
-       }
        res = xcalloc(1, sizeof(*res));
        while (fgets(buf, sizeof(buf), fp)) {
                char *bufp = buf;