attr: warn on inaccessible attribute files

Just like config and gitignore files, we silently ignore missing or inaccessible attribute files. An existent but inaccessible file is probably a configuration error, so let's warn the user. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 21, 2012 at 02:31 UTC 11e50b2736f374f1608e0c5690405be1a74aa16d
1 file changed +4 -1
attr.c
+4 -1
@@ -352,8 +352,11 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
352 char buf[2048];
353 int lineno = 0;
354
355 - if (!fp)
355 + if (!fp) {
356 + if (errno != ENOENT)
357 + warning(_("unable to access '%s': %s"), path, strerror(errno));
358 return NULL;
359 + }
360 res = xcalloc(1, sizeof(*res));
361 while (fgets(buf, sizeof(buf), fp))
362 handle_attr_line(res, buf, path, ++lineno, macro_ok);