]> gitweb.ps.run Git - ps-cgit/blobdiff - scan-tree.c
ui-patch.c: Fix signature delimiter
[ps-cgit] / scan-tree.c
index beb584b5952eb9407e90fc8c580ffffdb5dc5676..7cd8f08672e1f79c7b71432d4aa180a2a7ce8180 100644 (file)
@@ -1,7 +1,7 @@
 /* scan-tree.c
  * 
  * Copyright (C) 2008-2009 Lars Hjemli
- * Copyright (C) 2010, 2012 Jason A. Donenfeld <Jason@zx2c4.com>
+ * Copyright (C) 2010-2013 Jason A. Donenfeld <Jason@zx2c4.com>
  *
  * Licensed under GNU General Public License v2
  *   (see COPYING for full license text)
@@ -113,6 +113,8 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
 
        if (!strcmp(rel.buf + rel.len - 5, "/.git"))
                strbuf_setlen(&rel, rel.len - 5);
+       else if (rel.len && rel.buf[rel.len - 1] == '/')
+               strbuf_setlen(&rel, rel.len - 1);
 
        repo = cgit_add_repo(rel.buf);
        config_fn = fn;
@@ -145,21 +147,15 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
                strbuf_setlen(path, pathlen);
        }
 
-       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;
+               n = ctx.cfg.section_from_path;
                if (n > 0) {
-                       slash = rel.buf;
-                       while (slash && n && (slash = strchr(slash, '/')))
+                       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, '/')))
+                       while (slash && n && (slash = xstrrchr(rel.buf, slash - 1, '/')))
                                n++;
                }
                if (slash && !n) {