sha1_file: refactor read_object
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index 9efcf1eab689bd0e637ea1b961b261eb97862b04..17590638176f26e35f3a728e5cd56917e0568541 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -752,9 +752,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 (!istate ||
                    (buf = read_skip_worktree_file_from_index(istate, fname, &size, sha1_stat)) == NULL)
@@ -2337,7 +2337,7 @@ int remove_path(const char *name)
 {
        char *slash;
 
-       if (unlink(name) && errno != ENOENT && errno != ENOTDIR)
+       if (unlink(name) && !is_missing_file_error(errno))
                return -1;
 
        slash = strrchr(name, '/');