]> gitweb.ps.run Git - ps-cgit/blobdiff - scan-tree.c
authors: specify maintainers
[ps-cgit] / scan-tree.c
index 2684b446961686c9d48f785fc990bcbcd76db8e6..49de6583ff55852b6bd5af1c063e21d03d7c1d5d 100644 (file)
@@ -1,7 +1,6 @@
 /* scan-tree.c
- * 
- * Copyright (C) 2008-2009 Lars Hjemli
- * Copyright (C) 2010-2013 Jason A. Donenfeld <Jason@zx2c4.com>
+ *
+ * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
  *
  * Licensed under GNU General Public License v2
  *   (see COPYING for full license text)
@@ -106,7 +105,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
                return;
        strbuf_setlen(path, pathlen);
 
-       if (strncmp(base, path->buf, strlen(base)))
+       if (prefixcmp(path->buf, base))
                strbuf_addbuf(&rel, path);
        else
                strbuf_addstr(&rel, path->buf + strlen(base) + 1);
@@ -148,14 +147,14 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
        }
 
        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) {
@@ -230,8 +229,6 @@ end:
        closedir(dir);
 }
 
-#define lastc(s) s[strlen(s) - 1]
-
 void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn)
 {
        struct strbuf line = STRBUF_INIT;