- p = fmt("%s", path + strlen(base) + 1);
-
- if (!strcmp(p + strlen(p) - 5, "/.git"))
- p[strlen(p) - 5] = '\0';
-
- repo = cgit_add_repo(xstrdup(p));
- if (ctx.cfg.remove_suffix)
- if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git"))
- *p = '\0';
- repo->name = repo->url;
- repo->path = xstrdup(path);
- while (!owner) {
+ strbuf_addstr(&rel, path->buf + strlen(base) + 1);
+
+ if (!strcmp(rel.buf + rel.len - 5, "/.git"))
+ strbuf_setlen(&rel, rel.len - 5);
+ else if (rel.len && rel.buf[rel.len - 1] == '/')
+ strbuf_setlen(&rel, rel.len - 1);
+
+ repo = cgit_add_repo(rel.buf);
+ config_fn = fn;
+ if (ctx.cfg.enable_git_config) {
+ strbuf_addstr(path, "config");
+ git_config_from_file(gitconfig_config, path->buf, NULL);
+ strbuf_setlen(path, pathlen);
+ }
+
+ 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) {