Remove empty ref directories that prevent creating a ref.
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index d53d48f70c7f07a3fe5e6851467fc566b341aeb9..e2f472ba7f5d3e5146f110dd3eaae9e5494854e2 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -112,17 +112,15 @@ static int add_excludes_from_file_1(const char *fname,
                                    int baselen,
                                    struct exclude_list *which)
 {
+       struct stat st;
        int fd, i;
        long size;
        char *buf, *entry;
 
        fd = open(fname, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0 || fstat(fd, &st) < 0)
                goto err;
-       size = lseek(fd, 0, SEEK_END);
-       if (size < 0)
-               goto err;
-       lseek(fd, 0, SEEK_SET);
+       size = st.st_size;
        if (size == 0) {
                close(fd);
                return 0;
@@ -399,3 +397,10 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
        qsort(dir->entries, dir->nr, sizeof(struct dir_entry *), cmp_name);
        return dir->nr;
 }
+
+int
+file_exists(const char *f)
+{
+  struct stat sb;
+  return stat(f, &sb) == 0;
+}