Code

Remove "pathlen" from "struct name_entry"
[git.git] / dir.c
diff --git a/dir.c b/dir.c
index 8477472c03d2e1d5a4a76091792f6fe99327516c..b48e19dc09fff7d7fb1d5b48673fe4448b69a7c3 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -130,19 +130,19 @@ static int add_excludes_from_file_1(const char *fname,
 {
        struct stat st;
        int fd, i;
-       long size;
+       size_t size;
        char *buf, *entry;
 
        fd = open(fname, O_RDONLY);
        if (fd < 0 || fstat(fd, &st) < 0)
                goto err;
-       size = st.st_size;
+       size = xsize_t(st.st_size);
        if (size == 0) {
                close(fd);
                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,12 +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)
+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);
@@ -273,10 +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 = 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)
@@ -364,7 +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);
+                               dir_add_name(dir, fullname, baselen + len);
                }
 exit_early:
                closedir(fdir);