+ repo->path = xstrdup(path->buf);
+ while (!repo->owner) {
+ if ((pwd = getpwuid(st.st_uid)) == NULL) {
+ fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n",
+ path->buf, strerror(errno), errno);
+ break;
+ }
+ if (pwd->pw_gecos)
+ if ((p = strchr(pwd->pw_gecos, ',')))
+ *p = '\0';
+ repo->owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name);
+ }
+
+ if (repo->desc == cgit_default_repo_desc || !repo->desc) {
+ strbuf_addstr(path, "description");
+ if (!stat(path->buf, &st))
+ readfile(path->buf, &repo->desc, &size);
+ strbuf_setlen(path, pathlen);
+ }
+
+ if (ctx.cfg.section_from_path) {
+ n = ctx.cfg.section_from_path;
+ if (n > 0) {
+ slash = rel.buf - 1;
+ while (slash && n && (slash = strchr(slash + 1, '/')))
+ n--;
+ } else {
+ slash = rel.buf + rel.len;
+ while (slash && n && (slash = xstrrchr(rel.buf, slash - 1, '/')))
+ n++;
+ }
+ if (slash && !n) {
+ *slash = '\0';
+ repo->section = xstrdup(rel.buf);
+ *slash = '/';
+ if (starts_with(repo->name, repo->section)) {
+ repo->name += strlen(repo->section);
+ if (*repo->name == '/')
+ repo->name++;
+ }
+ }
+ }
+
+ strbuf_addstr(path, "cgitrc");
+ if (!stat(path->buf, &st))
+ parse_configfile(path->buf, &scan_tree_repo_config);
+
+ strbuf_release(&rel);