diff options
author | Lars Hjemli | 2011-06-06 19:29:58 +0000 |
---|---|---|
committer | Lars Hjemli | 2011-06-13 23:03:46 +0000 |
commit | 3ec6b309505dc5f7ba14abe8861b02da34a9df0b (patch) | |
tree | 4dda97c3b85d8103f05332677c6e0a15113f3cf3 /shared.c | |
parent | b88cda6e5b4472fc1bb0ae00d9fb974ec4f61d7a (diff) | |
download | cgit-3ec6b309505dc5f7ba14abe8861b02da34a9df0b.tar.gz cgit-3ec6b309505dc5f7ba14abe8861b02da34a9df0b.tar.bz2 cgit-3ec6b309505dc5f7ba14abe8861b02da34a9df0b.zip |
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 <mailings@hupie.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -374,7 +374,8 @@ typedef struct { | |||
374 | char * value; | 374 | char * value; |
375 | } cgit_env_var; | 375 | } cgit_env_var; |
376 | 376 | ||
377 | static void prepare_env(struct cgit_repo * repo) { | 377 | void cgit_prepare_repo_env(struct cgit_repo * repo) |
378 | { | ||
378 | cgit_env_var env_vars[] = { | 379 | cgit_env_var env_vars[] = { |
379 | { .name = "CGIT_REPO_URL", .value = repo->url }, | 380 | { .name = "CGIT_REPO_URL", .value = repo->url }, |
380 | { .name = "CGIT_REPO_NAME", .value = repo->name }, | 381 | { .name = "CGIT_REPO_NAME", .value = repo->name }, |
@@ -395,7 +396,7 @@ static void prepare_env(struct cgit_repo * repo) { | |||
395 | fprintf(stderr, warn, p->name, p->value); | 396 | fprintf(stderr, warn, p->name, p->value); |
396 | } | 397 | } |
397 | 398 | ||
398 | int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo) | 399 | int cgit_open_filter(struct cgit_filter *filter) |
399 | { | 400 | { |
400 | 401 | ||
401 | filter->old_stdout = chk_positive(dup(STDOUT_FILENO), | 402 | filter->old_stdout = chk_positive(dup(STDOUT_FILENO), |
@@ -406,8 +407,6 @@ int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo) | |||
406 | close(filter->pipe_fh[1]); | 407 | close(filter->pipe_fh[1]); |
407 | chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO), | 408 | chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO), |
408 | "Unable to use pipe as STDIN"); | 409 | "Unable to use pipe as STDIN"); |
409 | if (repo) | ||
410 | prepare_env(repo); | ||
411 | execvp(filter->cmd, filter->argv); | 410 | execvp(filter->cmd, filter->argv); |
412 | die("Unable to exec subprocess %s: %s (%d)", filter->cmd, | 411 | die("Unable to exec subprocess %s: %s (%d)", filter->cmd, |
413 | strerror(errno), errno); | 412 | strerror(errno), errno); |