]> git.cameronkatri.com Git - cgit.git/commitdiff
Remove trailing slash after remove-suffix
authorLukas Fleischer <cgit@cryptocrack.de>
Sat, 13 Dec 2014 10:40:48 +0000 (11:40 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 24 Dec 2014 01:53:03 +0000 (18:53 -0700)
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>
scan-tree.c

index 044bcdcfc4dd6a48df7bb06f0bbdfc40a89a7b70..e900ad9ff009a897f056bb0ceb183bcd37ed6f17 100644 (file)
@@ -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) {