]> granicus.if.org Git - cgit/commitdiff
Merge branch 'lh/section-from-path'
authorLars Hjemli <hjemli@gmail.com>
Sun, 19 Sep 2010 16:46:17 +0000 (18:46 +0200)
committerLars Hjemli <hjemli@gmail.com>
Sun, 19 Sep 2010 16:46:17 +0000 (18:46 +0200)
Conflicts:
scan-tree.c

1  2 
cgit.c
cgit.h
cgitrc.5.txt
scan-tree.c

diff --cc cgit.c
Simple merge
diff --cc cgit.h
Simple merge
diff --cc cgitrc.5.txt
Simple merge
diff --cc scan-tree.c
index 780d405425b283d096dda4dd86b89bcee5028f76,6ba9193e2e3d5c5894a5493b9db2cab328bbb095..b5b50f332b812e4afcd7622a57d84bcf653959a6
@@@ -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)) {