From: Lars Hjemli Date: Sun, 19 Sep 2010 16:46:17 +0000 (+0200) Subject: Merge branch 'lh/section-from-path' X-Git-Tag: v0.9~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=536c7a1eb201b44b9266babe087cb6f2b75e4a7f;p=cgit Merge branch 'lh/section-from-path' Conflicts: scan-tree.c --- 536c7a1eb201b44b9266babe087cb6f2b75e4a7f diff --cc scan-tree.c index 780d405,6ba9193..b5b50f3 --- a/scan-tree.c +++ b/scan-tree.c @@@ -110,11 -118,31 +118,33 @@@ static void add_repo(const char *base, if (!stat(p, &st)) readfile(p, &repo->desc, &size); - p = fmt("%s/README.html", path); - if (!stat(p, &st)) - repo->readme = "README.html"; + if (!repo->readme) { + p = fmt("%s/README.html", path); + if (!stat(p, &st)) + repo->readme = "README.html"; + } + if (ctx.cfg.section_from_path) { + n = ctx.cfg.section_from_path; + if (n > 0) { + slash = rel; + while (slash && n && (slash = strchr(slash, '/'))) + n--; + } else { + slash = rel + strlen(rel); + while (slash && n && (slash = xstrrchr(rel, slash, '/'))) + n++; + } + if (slash && !n) { + *slash = '\0'; + repo->section = xstrdup(rel); + *slash = '/'; + if (!prefixcmp(repo->name, repo->section)) { + repo->name += strlen(repo->section); + if (*repo->name == '/') + repo->name++; + } + } + } p = fmt("%s/cgitrc", path); if (!stat(p, &st)) {