Skip to content

Commit 6966073

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba8bd83 commit 6966073

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dir.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ int add_excludes_from_file_to_list(const char *fname,
397397

398398
fd = open(fname, O_RDONLY);
399399
if (fd < 0 || fstat(fd, &st) < 0) {
400+
if (errno != ENOENT)
401+
warning(_("unable to access '%s': %s"), fname, strerror(errno));
400402
if (0 <= fd)
401403
close(fd);
402404
if (!check_index ||
@@ -1311,9 +1313,9 @@ void setup_standard_excludes(struct dir_struct *dir)
13111313
home_config_paths(NULL, &xdg_path, "ignore");
13121314
excludes_file = xdg_path;
13131315
}
1314-
if (!access(path, R_OK))
1316+
if (!access_or_warn(path, R_OK))
13151317
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))
13171319
add_excludes_from_file(dir, excludes_file);
13181320
}
13191321

0 commit comments

Comments
 (0)