From 3ec6b309505dc5f7ba14abe8861b02da34a9df0b Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 6 Jun 2011 19:29:58 +0000 Subject: cgit.c: always setup cgit repo environment variables When cgit learned to setup environment variables for certain repo settings before invoking a filter process, the setup occurred inside cgit_open_filter(). This patch moves the setup out of cgit_open_filter() and into prepare_repo_cmd() to prepare for additional uses of these variables. Reviewed-by: Ferry Huberts Signed-off-by: Lars Hjemli --- shared.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'shared.c') diff --git a/shared.c b/shared.c index be2ae59..4adeaa8 100644 --- a/shared.c +++ b/shared.c @@ -374,7 +374,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 }, @@ -395,7 +396,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), @@ -406,8 +407,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); -- cgit v1.2.3-70-g09d2