]> gitweb.ps.run Git - ps-cgit/blobdiff - scan-tree.c
ui-patch: Flush stdout after outputting data
[ps-cgit] / scan-tree.c
index 29c8263a0f6feeea85545999adfeef41a8ab03ae..87fa0c78a96273c4f2504ae0132c340f6ee9ba4d 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)
@@ -62,7 +61,7 @@ static int gitconfig_config(const char *key, const char *value, void *cb)
                config_fn(repo, "desc", value);
        else if (!strcmp(key, "gitweb.category"))
                config_fn(repo, "section", value);
-       else if (!prefixcmp(key, "cgit."))
+       else if (starts_with(key, "cgit."))
                config_fn(repo, key + 5, value);
 
        return 0;
@@ -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 (!starts_with(path->buf, base))
                strbuf_addbuf(&rel, path);
        else
                strbuf_addstr(&rel, path->buf + strlen(base) + 1);
@@ -116,6 +115,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
        else if (rel.len && rel.buf[rel.len - 1] == '/')
                strbuf_setlen(&rel, rel.len - 1);
 
+       fprintf(stderr, "add_repo(): %s\n", rel.buf);
        repo = cgit_add_repo(rel.buf);
        config_fn = fn;
        if (ctx.cfg.enable_git_config) {
@@ -162,7 +162,8 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
                        *slash = '\0';
                        repo->section = xstrdup(rel.buf);
                        *slash = '/';
-                       if (!prefixcmp(repo->name, repo->section)) {
+                       fprintf(stderr, "repo->name %s, repo->section %s\n", repo->name, repo->section);
+                       if (starts_with(repo->name, repo->section)) {
                                repo->name += strlen(repo->section);
                                if (*repo->name == '/')
                                        repo->name++;
@@ -185,6 +186,7 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn)
        size_t pathlen = strlen(path);
        struct stat st;
 
+       fprintf(stderr, "scan_path(): %s\n", path);
        if (!dir) {
                fprintf(stderr, "Error opening directory %s: %s (%d)\n",
                        path, strerror(errno), errno);
@@ -193,6 +195,7 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn)
 
        strbuf_add(&pathbuf, path, strlen(path));
        if (is_git_dir(pathbuf.buf)) {
+               fprintf(stderr, "scan_path() is_git_dir: %s\n", path);
                add_repo(base, &pathbuf, fn);
                goto end;
        }