summaryrefslogtreecommitdiff
path: root/scan-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'scan-tree.c')
-rw-r--r--scan-tree.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/scan-tree.c b/scan-tree.c
index 47f3988..4da21a4 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -35,25 +35,13 @@ static int is_git_dir(const char *path)
return 1;
}
-char *readfile(const char *path)
-{
- FILE *f;
- static char buf[MAX_PATH];
-
- if (!(f = fopen(path, "r")))
- return NULL;
- buf[0] = 0;
- fgets(buf, MAX_PATH, f);
- fclose(f);
- return buf;
-}
-
static void add_repo(const char *base, const char *path)
{
struct cgit_repo *repo;
struct stat st;
struct passwd *pwd;
char *p;
+ size_t size;
if (stat(path, &st)) {
fprintf(stderr, "Error accessing %s: %s (%d)\n",
@@ -76,11 +64,14 @@ static void add_repo(const char *base, const char *path)
repo = cgit_add_repo(xstrdup(p));
repo->name = repo->url;
repo->path = xstrdup(path);
+ p = (pwd && pwd->pw_gecos) ? strchr(pwd->pw_gecos, ',') : NULL;
+ if (p)
+ *p = '\0';
repo->owner = (pwd ? xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name) : "");
p = fmt("%s/description", path);
if (!stat(p, &st))
- repo->desc = xstrdup(readfile(p));
+ readfile(p, &repo->desc, &size);
p = fmt("%s/README.html", path);
if (!stat(p, &st))