| -rw-r--r-- | cgit.c | 1 | ||||
| -rw-r--r-- | cgit.h | 4 | ||||
| -rw-r--r-- | shared.c | 7 | ||||
| -rw-r--r-- | ui-commit.c | 6 | ||||
| -rw-r--r-- | ui-repolist.c | 2 | ||||
| -rw-r--r-- | ui-snapshot.c | 2 | ||||
| -rw-r--r-- | ui-summary.c | 2 | ||||
| -rw-r--r-- | ui-tree.c | 2 |
8 files changed, 12 insertions, 14 deletions
@@ -463,7 +463,6 @@ static int prepare_repo_cmd(struct cgit_context *ctx) cgit_print_docend(); return 1; } - cgit_prepare_repo_env(ctx->repo); return 0; } @@ -319,11 +319,9 @@ extern const char *cgit_repobasename(const char *reponame); extern int cgit_parse_snapshots_mask(const char *str); -extern int cgit_open_filter(struct cgit_filter *filter); +extern int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo); extern int cgit_close_filter(struct cgit_filter *filter); -extern void cgit_prepare_repo_env(struct cgit_repo * repo); - extern int readfile(const char *path, char **buf, size_t *size); extern char *expand_macros(const char *txt); @@ -374,8 +374,7 @@ typedef struct { char * value; } cgit_env_var; -void cgit_prepare_repo_env(struct cgit_repo * repo) -{ +static void prepare_env(struct cgit_repo * repo) { cgit_env_var env_vars[] = { { .name = "CGIT_REPO_URL", .value = repo->url }, { .name = "CGIT_REPO_NAME", .value = repo->name }, @@ -396,7 +395,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo) fprintf(stderr, warn, p->name, p->value); } -int cgit_open_filter(struct cgit_filter *filter) +int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo) { filter->old_stdout = chk_positive(dup(STDOUT_FILENO), @@ -407,6 +406,8 @@ int cgit_open_filter(struct cgit_filter *filter) 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); diff --git a/ui-commit.c b/ui-commit.c index 536a8e8..a69dec6 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -106,7 +106,7 @@ void cgit_print_commit(char *hex, const char *prefix) html("</table>\n"); html("<div class='commit-subject'>"); if (ctx.repo->commit_filter) - cgit_open_filter(ctx.repo->commit_filter); + cgit_open_filter(ctx.repo->commit_filter, ctx.repo); html_txt(info->subject); if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter); @@ -114,7 +114,7 @@ void cgit_print_commit(char *hex, const char *prefix) html("</div>"); html("<div class='commit-msg'>"); if (ctx.repo->commit_filter) - cgit_open_filter(ctx.repo->commit_filter); + cgit_open_filter(ctx.repo->commit_filter, ctx.repo); html_txt(info->msg); if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter); @@ -123,7 +123,7 @@ void cgit_print_commit(char *hex, const char *prefix) html("<div class='notes-header'>Notes</div>"); html("<div class='notes'>"); if (ctx.repo->commit_filter) - cgit_open_filter(ctx.repo->commit_filter); + cgit_open_filter(ctx.repo->commit_filter, ctx.repo); html_txt(notes.buf); if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter); diff --git a/ui-repolist.c b/ui-repolist.c index 25c36ce..dce2eac 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -300,7 +300,7 @@ void cgit_print_site_readme() if (!ctx.cfg.root_readme) return; if (ctx.cfg.about_filter) - cgit_open_filter(ctx.cfg.about_filter); + cgit_open_filter(ctx.cfg.about_filter, NULL); html_include(ctx.cfg.root_readme); if (ctx.cfg.about_filter) cgit_close_filter(ctx.cfg.about_filter); diff --git a/ui-snapshot.c b/ui-snapshot.c index 07cc944..126779d 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -19,7 +19,7 @@ static int write_compressed_tar_archive(struct archiver_args *args,const char *f f.argv = malloc(2 * sizeof(char *)); f.argv[0] = f.cmd; f.argv[1] = NULL; - cgit_open_filter(&f); + cgit_open_filter(&f, NULL); rv = write_tar_archive(args); cgit_close_filter(&f); return rv; diff --git a/ui-summary.c b/ui-summary.c index 5be2545..1e9a1b6 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -113,7 +113,7 @@ void cgit_print_repo_readme(char *path) */ html("<div id='summary'>"); if (ctx.repo->about_filter) - cgit_open_filter(ctx.repo->about_filter); + cgit_open_filter(ctx.repo->about_filter, ctx.repo); if (ref) cgit_print_file(tmp, ref); else @@ -45,7 +45,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) if (ctx.repo->source_filter) { html("<td class='lines'><pre><code>"); ctx.repo->source_filter->argv[1] = xstrdup(name); - cgit_open_filter(ctx.repo->source_filter); + cgit_open_filter(ctx.repo->source_filter, ctx.repo); html_raw(buf, size); cgit_close_filter(ctx.repo->source_filter); free(ctx.repo->source_filter->argv[1]); |