]> gitweb.ps.run Git - ps-cgit/blobdiff - shared.c
Merge branch 'stable'
[ps-cgit] / shared.c
index 986f965dc872d784b8b96f27003630fd6971933d..699c3624b1d67b28b8c111b6479df4c9bad43477 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -70,6 +70,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
        ret->about_filter = ctx.cfg.about_filter;
        ret->commit_filter = ctx.cfg.commit_filter;
        ret->source_filter = ctx.cfg.source_filter;
+       ret->clone_url = ctx.cfg.clone_url;
        return ret;
 }
 
@@ -102,23 +103,15 @@ void *cgit_free_commitinfo(struct commitinfo *info)
 char *trim_end(const char *str, char c)
 {
        int len;
-       char *s, *t;
 
        if (str == NULL)
                return NULL;
-       t = (char *)str;
-       len = strlen(t);
-       while(len > 0 && t[len - 1] == c)
+       len = strlen(str);
+       while(len > 0 && str[len - 1] == c)
                len--;
-
        if (len == 0)
                return NULL;
-
-       c = t[len];
-       t[len] = '\0';
-       s = xstrdup(t);
-       t[len] = c;
-       return s;
+       return xstrndup(str, len);
 }
 
 char *strlpart(char *txt, int maxlen)
@@ -313,7 +306,6 @@ void cgit_diff_tree(const unsigned char *old_sha1,
                    filepair_fn fn, const char *prefix, int ignorews)
 {
        struct diff_options opt;
-       int ret;
        int prefixlen;
 
        diff_setup(&opt);
@@ -334,9 +326,9 @@ void cgit_diff_tree(const unsigned char *old_sha1,
        diff_setup_done(&opt);
 
        if (old_sha1 && !is_null_sha1(old_sha1))
-               ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt);
+               diff_tree_sha1(old_sha1, new_sha1, "", &opt);
        else
-               ret = diff_root_tree_sha1(new_sha1, "", &opt);
+               diff_root_tree_sha1(new_sha1, "", &opt);
        diffcore_std(&opt);
        diff_flush(&opt);
 }
@@ -383,7 +375,8 @@ typedef struct {
        char * value;
 } cgit_env_var;
 
-static void prepare_env(struct cgit_repo * repo) {
+void cgit_prepare_repo_env(struct cgit_repo * repo)
+{
        cgit_env_var env_vars[] = {
                { .name = "CGIT_REPO_URL", .value = repo->url },
                { .name = "CGIT_REPO_NAME", .value = repo->name },
@@ -404,7 +397,7 @@ static void prepare_env(struct cgit_repo * repo) {
                        fprintf(stderr, warn, p->name, p->value);
 }
 
-int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo)
+int cgit_open_filter(struct cgit_filter *filter)
 {
 
        filter->old_stdout = chk_positive(dup(STDOUT_FILENO),
@@ -415,8 +408,6 @@ int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo)
                close(filter->pipe_fh[1]);
                chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO),
                        "Unable to use pipe as STDIN");
-               if (repo)
-                       prepare_env(repo);
                execvp(filter->cmd, filter->argv);
                die("Unable to exec subprocess %s: %s (%d)", filter->cmd,
                        strerror(errno), errno);