summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2017-05-03 10:16:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-26 03:33:55 (GMT)
commit11dc1fcb3fa53f5a46486daa7cb38ed387153f2e (patch)
tree98bf996bbac5e5c0b85ee1673a83d14a8ae0fbab /dir.c
parent8e178ec4d072da4cd8f4449e17aef3aff5b57f6a (diff)
downloadgit-11dc1fcb3fa53f5a46486daa7cb38ed387153f2e.zip
git-11dc1fcb3fa53f5a46486daa7cb38ed387153f2e.tar.gz
git-11dc1fcb3fa53f5a46486daa7cb38ed387153f2e.tar.bz2
wrapper.c: add and use warn_on_fopen_errors()
In many places, Git warns about an inaccessible file after a fopen() failed. To discern these cases from other cases where we want to warn about inaccessible files, introduce a new helper specifically to test whether fopen() failed because the current user lacks the permission to open file in question. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/dir.c b/dir.c
index f451bfa..be616e8 100644
--- a/dir.c
+++ b/dir.c
@@ -745,9 +745,9 @@ static int add_excludes(const char *fname, const char *base, int baselen,
fd = open(fname, O_RDONLY);
if (fd < 0 || fstat(fd, &st) < 0) {
- if (errno != ENOENT)
- warn_on_inaccessible(fname);
- if (0 <= fd)
+ if (fd < 0)
+ warn_on_fopen_errors(fname);
+ else
close(fd);
if (!check_index ||
(buf = read_skip_worktree_file_from_index(fname, &size, sha1_stat)) == NULL)