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)
{
static int gitconfig_config(const char *key, const char *value, void *cb)
{
+ const char *name;
+
if (!strcmp(key, "gitweb.owner"))
config_fn(repo, "owner", value);
else if (!strcmp(key, "gitweb.description"))
config_fn(repo, "desc", value);
else if (!strcmp(key, "gitweb.category"))
config_fn(repo, "section", value);
- else if (starts_with(key, "cgit."))
- config_fn(repo, key + 5, value);
+ else if (!strcmp(key, "gitweb.homepage"))
+ config_fn(repo, "homepage", value);
+ else if (skip_prefix(key, "cgit.", &name))
+ config_fn(repo, name, value);
return 0;
}
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) {
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) {
*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 == '/')
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);
}
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);
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;
}
projectsfile, strerror(errno), errno);
return;
}
- while (strbuf_getline(&line, projects, '\n') != EOF) {
+ while (strbuf_getline(&line, projects) != EOF) {
if (!line.len)
continue;
strbuf_insert(&line, 0, "/", 1);