aboutsummaryrefslogtreecommitdiff
path: root/scan-tree.c
diff options
context:
space:
mode:
authorLukas Fleischer <cgit@cryptocrack.de>2014-12-13 11:40:48 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2014-12-23 18:53:03 -0700
commit485b09925cd54f3f55257619fa5796d274e96050 (patch)
tree631b00ace022799631e89968bd865da7549d7fa1 /scan-tree.c
parent17838ec6304198811df97402f11c185f8f0e10bd (diff)
downloadcgit-485b09925cd54f3f55257619fa5796d274e96050.tar.gz
cgit-485b09925cd54f3f55257619fa5796d274e96050.tar.bz2
Remove trailing slash after remove-suffix
When removing the ".git" suffix of a non-bare repository, also remove the trailing slash for compatibility with cgit_repobasename(). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'scan-tree.c')
-rw-r--r--scan-tree.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/scan-tree.c b/scan-tree.c
index 044bcdc..e900ad9 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -123,9 +123,12 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
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) {