summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <cgit@cryptocrack.de>2014-12-13 10:40:48 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2014-12-24 01:53:03 +0000
commit485b09925cd54f3f55257619fa5796d274e96050 (patch)
tree631b00ace022799631e89968bd865da7549d7fa1
parent17838ec6304198811df97402f11c185f8f0e10bd (diff)
downloadcgit-485b09925cd54f3f55257619fa5796d274e96050.tar
cgit-485b09925cd54f3f55257619fa5796d274e96050.tar.gz
cgit-485b09925cd54f3f55257619fa5796d274e96050.zip
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>
-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) {