for-each-reflog: not having $GIT_DIR/logs directory is not an error.
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index dd188a8c56c02e1bbe2c8fc0cfb9ce67cdeb948d..32b57f0125d1b9e95345eb23a9a32fbf8444b1b8 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -142,7 +142,7 @@ static int add_excludes_from_file_1(const char *fname,
                return 0;
        }
        buf = xmalloc(size+1);
-       if (read(fd, buf, size) != size)
+       if (read_in_full(fd, buf, size) != size)
                goto err;
        close(fd);
 
@@ -260,13 +260,12 @@ int excluded(struct dir_struct *dir, const char *pathname)
        return 0;
 }
 
-static void add_name(struct dir_struct *dir, const char *pathname, int len,
-                    int ignored_entry)
+struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
 {
        struct dir_entry *ent;
 
        if (cache_name_pos(pathname, len) >= 0)
-               return;
+               return NULL;
 
        if (dir->nr == dir->alloc) {
                int alloc = alloc_nr(dir->alloc);
@@ -274,11 +273,12 @@ static void add_name(struct dir_struct *dir, const char *pathname, int len,
                dir->entries = xrealloc(dir->entries, alloc*sizeof(ent));
        }
        ent = xmalloc(sizeof(*ent) + len + 1);
-       ent->ignored_entry = ignored_entry;
+       ent->ignored = ent->ignored_dir = 0;
        ent->len = len;
        memcpy(ent->name, pathname, len);
        ent->name[len] = 0;
        dir->entries[dir->nr++] = ent;
+       return ent;
 }
 
 static int dir_exists(const char *dirname, int len)
@@ -316,7 +316,6 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
 
                while ((de = readdir(fdir)) != NULL) {
                        int len;
-                       int ignored_entry;
 
                        if ((de->d_name[0] == '.') &&
                            (de->d_name[1] == 0 ||
@@ -325,12 +324,11 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
                                continue;
                        len = strlen(de->d_name);
                        memcpy(fullname + baselen, de->d_name, len+1);
-                       ignored_entry = excluded(dir, fullname);
-
-                       if (!dir->show_both &&
-                           (ignored_entry != dir->show_ignored) &&
-                           (!dir->show_ignored || DTYPE(de) != DT_DIR))
-                               continue;
+                       if (excluded(dir, fullname) != dir->show_ignored) {
+                               if (!dir->show_ignored || DTYPE(de) != DT_DIR) {
+                                       continue;
+                               }
+                       }
 
                        switch (DTYPE(de)) {
                        struct stat st;
@@ -368,8 +366,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
                        if (check_only)
                                goto exit_early;
                        else
-                               add_name(dir, fullname, baselen + len,
-                                        ignored_entry);
+                               dir_add_name(dir, fullname, baselen + len);
                }
 exit_early:
                closedir(fdir);