all repos — cgit @ 485b09925cd54f3f55257619fa5796d274e96050

a hyperfast web frontend for git written in c

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>
Lukas Fleischer cgit@cryptocrack.de
Sat, 13 Dec 2014 11:40:48 +0100
commit

485b09925cd54f3f55257619fa5796d274e96050

parent

17838ec6304198811df97402f11c185f8f0e10bd

1 files changed, 6 insertions(+), 3 deletions(-)

jump to
M scan-tree.cscan-tree.c

@@ -123,9 +123,12 @@ git_config_from_file(gitconfig_config, path->buf, NULL);

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) {