X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/79c985e13c10b498c3ea62f4607c2e2a460c3b10..143e65252c1c842774bc5a601d5faef97ca6c886:/scan-tree.c?ds=sidebyside diff --git a/scan-tree.c b/scan-tree.c index 87fa0c7..b5a10ff 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -45,8 +45,8 @@ out: return result; } -struct cgit_repo *repo; -repo_config_fn config_fn; +static struct cgit_repo *repo; +static repo_config_fn config_fn; static void repo_config(const char *name, const char *value) { @@ -115,7 +115,6 @@ 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) { @@ -124,9 +123,12 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) strbuf_setlen(path, pathlen); } - if (ctx.cfg.remove_suffix) - if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) - *p = '\0'; + if (ctx.cfg.remove_suffix) { + size_t urllen; + strip_suffix(repo->url, ".git", &urllen); + strip_suffix_mem(repo->url, &urllen, "/"); + repo->url[urllen] = '\0'; + } repo->path = xstrdup(path->buf); while (!repo->owner) { if ((pwd = getpwuid(st.st_uid)) == NULL) { @@ -162,7 +164,6 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) *slash = '\0'; repo->section = xstrdup(rel.buf); *slash = '/'; - 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 == '/') @@ -173,7 +174,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) strbuf_addstr(path, "cgitrc"); if (!stat(path->buf, &st)) - parse_configfile(xstrdup(path->buf), &repo_config); + parse_configfile(path->buf, &repo_config); strbuf_release(&rel); } @@ -186,7 +187,6 @@ 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); @@ -195,7 +195,6 @@ 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; }