gitignore: report access errors of exclude files

When we try to access gitignore files, we check for their existence with a call to "access". We silently ignore missing files. However, if a file is not readable, this may be a configuration error; let's warn the user. For $GIT_DIR/info/excludes or core.excludesfile, we can just use access_or_warn. However, for per-directory files we actually try to open them, so we must add a custom warning. 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:26 UTC 6966073102170171da4c25a4038bbd143fa6a75b
1 file changed +4 -2
dir.c
+4 -2
@@ -397,6 +397,8 @@ int add_excludes_from_file_to_list(const char *fname,
397
398 fd = open(fname, O_RDONLY);
399 if (fd < 0 || fstat(fd, &st) < 0) {
400 + if (errno != ENOENT)
401 + warning(_("unable to access '%s': %s"), fname, strerror(errno));
402 if (0 <= fd)
403 close(fd);
404 if (!check_index ||
@@ -1311,9 +1313,9 @@ void setup_standard_excludes(struct dir_struct *dir)
1313 home_config_paths(NULL, &xdg_path, "ignore");
1314 excludes_file = xdg_path;
1315 }
1314 - if (!access(path, R_OK))
1316 + if (!access_or_warn(path, R_OK))
1317 add_excludes_from_file(dir, path);
1316 - if (excludes_file && !access(excludes_file, R_OK))
1318 + if (excludes_file && !access_or_warn(excludes_file, R_OK))
1319 add_excludes_from_file(dir, excludes_file);
1320 }
1321