ls-files: use repository object
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index 9efcf1eab689bd0e637ea1b961b261eb97862b04..34445374ba60b5a2e8d1c2b6e96ba7dbdb18eb4c 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -9,6 +9,7 @@
  */
 #define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
+#include "config.h"
 #include "dir.h"
 #include "attr.h"
 #include "refs.h"
@@ -752,9 +753,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)
@@ -795,7 +796,7 @@ static int add_excludes(const char *fname, const char *base, int baselen,
                                 (pos = index_name_pos(istate, fname, strlen(fname))) >= 0 &&
                                 !ce_stage(istate->cache[pos]) &&
                                 ce_uptodate(istate->cache[pos]) &&
-                                !would_convert_to_git(fname))
+                                !would_convert_to_git(istate, fname))
                                hashcpy(sha1_stat->sha1,
                                        istate->cache[pos]->oid.hash);
                        else
@@ -2337,7 +2338,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, '/');