]> gitweb.ps.run Git - ps-cgit/blobdiff - scan-tree.c
ui-shared: redirect should not exit early for cache
[ps-cgit] / scan-tree.c
index 044bcdcfc4dd6a48df7bb06f0bbdfc40a89a7b70..2e87999b11b8f10fdbeab0c9b2b20e22b7b46184 100644 (file)
@@ -45,8 +45,8 @@ out:
        return result;
 }
 
-struct cgit_repo *repo;
-repo_config_fn config_fn;
+static struct cgit_repo *repo;
+static repo_config_fn config_fn;
 
 static void repo_config(const char *name, const char *value)
 {
@@ -61,6 +61,8 @@ static int gitconfig_config(const char *key, const char *value, void *cb)
                config_fn(repo, "desc", value);
        else if (!strcmp(key, "gitweb.category"))
                config_fn(repo, "section", value);
+       else if (!strcmp(key, "gitweb.homepage"))
+               config_fn(repo, "homepage", value);
        else if (starts_with(key, "cgit."))
                config_fn(repo, key + 5, value);
 
@@ -123,9 +125,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) {
@@ -171,7 +176,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
 
        strbuf_addstr(path, "cgitrc");
        if (!stat(path->buf, &st))
-               parse_configfile(xstrdup(path->buf), &repo_config);
+               parse_configfile(path->buf, &repo_config);
 
        strbuf_release(&rel);
 }