diff options
author | Lukas Fleischer | 2014-12-13 11:40:48 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2014-12-23 18:53:03 -0700 |
commit | 485b09925cd54f3f55257619fa5796d274e96050 (patch) | |
tree | 631b00ace022799631e89968bd865da7549d7fa1 | |
parent | 17838ec6304198811df97402f11c185f8f0e10bd (diff) | |
download | cgit-485b09925cd54f3f55257619fa5796d274e96050.tar.gz |
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 '')
-rw-r--r-- | scan-tree.c | 9 |
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) { |