- p = fmt("%s/cgitrc", path);
- if (!stat(p, &st)) {
- config_fn = fn;
- parse_configfile(xstrdup(p), &repo_config);
+ if (!repo->readme) {
+ strbuf_addstr(path, "README.html");
+ if (!stat(path->buf, &st))
+ repo->readme = "README.html";
+ strbuf_setlen(path, pathlen);
+ }
+ if (ctx.cfg.section_from_path) {
+ n = ctx.cfg.section_from_path;
+ if (n > 0) {
+ slash = rel.buf;
+ while (slash && n && (slash = strchr(slash, '/')))
+ n--;
+ } else {
+ slash = rel.buf + rel.len;
+ while (slash && n && (slash = xstrrchr(rel.buf, slash, '/')))
+ n++;
+ }
+ if (slash && !n) {
+ *slash = '\0';
+ repo->section = xstrdup(rel.buf);
+ *slash = '/';
+ if (!prefixcmp(repo->name, repo->section)) {
+ repo->name += strlen(repo->section);
+ if (*repo->name == '/')
+ repo->name++;
+ }
+ }