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)
{
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;
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);
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 = '/';
- if (!prefixcmp(repo->name, repo->section)) {
+ if (starts_with(repo->name, repo->section)) {
repo->name += strlen(repo->section);
if (*repo->name == '/')
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);
}