aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/shared.c b/shared.c
index 3778a5b..0c8ce3e 100644
--- a/shared.c
+++ b/shared.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include <stdio.h>
10 11
11struct cgit_repolist cgit_repolist; 12struct cgit_repolist cgit_repolist;
12struct cgit_context ctx; 13struct cgit_context ctx;
@@ -68,6 +69,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
68 ret->about_filter = ctx.cfg.about_filter; 69 ret->about_filter = ctx.cfg.about_filter;
69 ret->commit_filter = ctx.cfg.commit_filter; 70 ret->commit_filter = ctx.cfg.commit_filter;
70 ret->source_filter = ctx.cfg.source_filter; 71 ret->source_filter = ctx.cfg.source_filter;
72 ret->clone_url = ctx.cfg.clone_url;
71 return ret; 73 return ret;
72} 74}
73 75
@@ -367,6 +369,33 @@ int cgit_parse_snapshots_mask(const char *str)
367 return rv; 369 return rv;
368} 370}
369 371
372typedef struct {
373 char * name;
374 char * value;
375} cgit_env_var;
376
377void cgit_prepare_repo_env(struct cgit_repo * repo)
378{
379 cgit_env_var env_vars[] = {
380 { .name = "CGIT_REPO_URL", .value = repo->url },
381 { .name = "CGIT_REPO_NAME", .value = repo->name },
382 { .name = "CGIT_REPO_PATH", .value = repo->path },
383 { .name = "CGIT_REPO_OWNER", .value = repo->owner },
384 { .name = "CGIT_REPO_DEFBRANCH", .value = repo->defbranch },
385 { .name = "CGIT_REPO_SECTION", .value = repo->section },
386 { .name = "CGIT_REPO_CLONE_URL", .value = repo->clone_url }
387 };
388 int env_var_count = ARRAY_SIZE(env_vars);
389 cgit_env_var *p, *q;
390 static char *warn = "cgit warning: failed to set env: %s=%s\n";
391
392 p = env_vars;
393 q = p + env_var_count;
394 for (; p < q; p++)
395 if (p->value && setenv(p->name, p->value, 1))
396 fprintf(stderr, warn, p->name, p->value);
397}
398
370int cgit_open_filter(struct cgit_filter *filter) 399int cgit_open_filter(struct cgit_filter *filter)
371{ 400{
372 401