- if (ctx.cfg.enable_git_config)
- git_config_from_file(gitconfig_config, fmt("%s/config", path), NULL);
-
- if (ctx.cfg.remove_suffix)
- if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git"))
- *p = '\0';
- repo->path = xstrdup(path);
+ 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);