builtin/fetch: factor submodule recurse parsing out to submodule config
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index 9efcf1eab689bd0e637ea1b961b261eb97862b04..5f1afb56bc6e6d5dc5300380f980f4b2699ab08d 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -52,6 +52,15 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
 static int get_dtype(struct dirent *de, struct index_state *istate,
                     const char *path, int len);
 
+int count_slashes(const char *s)
+{
+       int cnt = 0;
+       while (*s)
+               if (*s++ == '/')
+                       cnt++;
+       return cnt;
+}
+
 int fspathcmp(const char *a, const char *b)
 {
        return ignore_case ? strcasecmp(a, b) : strcmp(a, b);
@@ -752,9 +761,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 +2346,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, '/');