]> git.cameronkatri.com Git - cgit.git/blobdiff - shared.c
Optionally generate verbose parent links
[cgit.git] / shared.c
index 9475581b2c4a20d73b639223156b8a7afbd5b5ca..83ded44de93b4343364ddfacedc94e9672008a02 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -48,6 +48,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
        }
 
        ret = &cgit_repolist.repos[cgit_repolist.count-1];
+       memset(ret, 0, sizeof(struct cgit_repo));
        ret->url = trim_end(url, '/');
        ret->name = ret->url;
        ret->path = NULL;
@@ -58,6 +59,8 @@ struct cgit_repo *cgit_add_repo(const char *url)
        ret->snapshots = ctx.cfg.snapshots;
        ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
        ret->enable_log_linecount = ctx.cfg.enable_log_linecount;
+       ret->enable_remote_branches = ctx.cfg.enable_remote_branches;
+       ret->enable_subject_links = ctx.cfg.enable_subject_links;
        ret->max_stats = ctx.cfg.max_stats;
        ret->module_link = ctx.cfg.module_link;
        ret->readme = NULL;
@@ -399,18 +402,25 @@ int cgit_close_filter(struct cgit_filter *filter)
  */
 int readfile(const char *path, char **buf, size_t *size)
 {
-       int fd;
+       int fd, e;
        struct stat st;
 
        fd = open(path, O_RDONLY);
        if (fd == -1)
                return errno;
-       if (fstat(fd, &st))
-               return errno;
-       if (!S_ISREG(st.st_mode))
+       if (fstat(fd, &st)) {
+               e = errno;
+               close(fd);
+               return e;
+       }
+       if (!S_ISREG(st.st_mode)) {
+               close(fd);
                return EISDIR;
+       }
        *buf = xmalloc(st.st_size + 1);
        *size = read_in_full(fd, *buf, st.st_size);
+       e = errno;
        (*buf)[*size] = '\0';
-       return (*size == st.st_size ? 0 : errno);
+       close(fd);
+       return (*size == st.st_size ? 0 : e);
 }