+ 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) {
+ if ((pwd = getpwuid(st.st_uid)) == NULL) {
+ fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n",
+ path->buf, strerror(errno), errno);
+ break;
+ }
+ if (pwd->pw_gecos)
+ if ((p = strchr(pwd->pw_gecos, ',')))
+ *p = '\0';
+ repo->owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name);
+ }