diff options
| -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, 14 insertions, 12 deletions
| @@ -463,6 +463,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx) | |||
| 463 | cgit_print_docend(); | 463 | cgit_print_docend(); |
| 464 | return 1; | 464 | return 1; |
| 465 | } | 465 | } |
| 466 | cgit_prepare_repo_env(ctx->repo); | ||
| 466 | return 0; | 467 | return 0; |
| 467 | } | 468 | } |
| 468 | 469 | ||
| @@ -319,9 +319,11 @@ extern const char *cgit_repobasename(const char *reponame); | |||
| 319 | 319 | ||
| 320 | extern int cgit_parse_snapshots_mask(const char *str); | 320 | extern int cgit_parse_snapshots_mask(const char *str); |
| 321 | 321 | ||
| 322 | extern int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo); | 322 | extern int cgit_open_filter(struct cgit_filter *filter); |
| 323 | extern int cgit_close_filter(struct cgit_filter *filter); | 323 | extern int cgit_close_filter(struct cgit_filter *filter); |
| 324 | 324 | ||
| 325 | extern void cgit_prepare_repo_env(struct cgit_repo * repo); | ||
| 326 | |||
| 325 | extern int readfile(const char *path, char **buf, size_t *size); | 327 | extern int readfile(const char *path, char **buf, size_t *size); |
| 326 | 328 | ||
| 327 | extern char *expand_macros(const char *txt); | 329 | extern char *expand_macros(const char *txt); |
| @@ -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); |
diff --git a/ui-commit.c b/ui-commit.c index a69dec6..536a8e8 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
| @@ -106,7 +106,7 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
| 106 | html("</table>\n"); | 106 | html("</table>\n"); |
| 107 | html("<div class='commit-subject'>"); | 107 | html("<div class='commit-subject'>"); |
| 108 | if (ctx.repo->commit_filter) | 108 | if (ctx.repo->commit_filter) |
| 109 | cgit_open_filter(ctx.repo->commit_filter, ctx.repo); | 109 | cgit_open_filter(ctx.repo->commit_filter); |
| 110 | html_txt(info->subject); | 110 | html_txt(info->subject); |
| 111 | if (ctx.repo->commit_filter) | 111 | if (ctx.repo->commit_filter) |
| 112 | cgit_close_filter(ctx.repo->commit_filter); | 112 | cgit_close_filter(ctx.repo->commit_filter); |
| @@ -114,7 +114,7 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
| 114 | html("</div>"); | 114 | html("</div>"); |
| 115 | html("<div class='commit-msg'>"); | 115 | html("<div class='commit-msg'>"); |
| 116 | if (ctx.repo->commit_filter) | 116 | if (ctx.repo->commit_filter) |
| 117 | cgit_open_filter(ctx.repo->commit_filter, ctx.repo); | 117 | cgit_open_filter(ctx.repo->commit_filter); |
| 118 | html_txt(info->msg); | 118 | html_txt(info->msg); |
| 119 | if (ctx.repo->commit_filter) | 119 | if (ctx.repo->commit_filter) |
| 120 | cgit_close_filter(ctx.repo->commit_filter); | 120 | cgit_close_filter(ctx.repo->commit_filter); |
| @@ -123,7 +123,7 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
| 123 | html("<div class='notes-header'>Notes</div>"); | 123 | html("<div class='notes-header'>Notes</div>"); |
| 124 | html("<div class='notes'>"); | 124 | html("<div class='notes'>"); |
| 125 | if (ctx.repo->commit_filter) | 125 | if (ctx.repo->commit_filter) |
| 126 | cgit_open_filter(ctx.repo->commit_filter, ctx.repo); | 126 | cgit_open_filter(ctx.repo->commit_filter); |
| 127 | html_txt(notes.buf); | 127 | html_txt(notes.buf); |
| 128 | if (ctx.repo->commit_filter) | 128 | if (ctx.repo->commit_filter) |
| 129 | cgit_close_filter(ctx.repo->commit_filter); | 129 | cgit_close_filter(ctx.repo->commit_filter); |
diff --git a/ui-repolist.c b/ui-repolist.c index dce2eac..25c36ce 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
| @@ -300,7 +300,7 @@ void cgit_print_site_readme() | |||
| 300 | if (!ctx.cfg.root_readme) | 300 | if (!ctx.cfg.root_readme) |
| 301 | return; | 301 | return; |
| 302 | if (ctx.cfg.about_filter) | 302 | if (ctx.cfg.about_filter) |
| 303 | cgit_open_filter(ctx.cfg.about_filter, NULL); | 303 | cgit_open_filter(ctx.cfg.about_filter); |
| 304 | html_include(ctx.cfg.root_readme); | 304 | html_include(ctx.cfg.root_readme); |
| 305 | if (ctx.cfg.about_filter) | 305 | if (ctx.cfg.about_filter) |
| 306 | cgit_close_filter(ctx.cfg.about_filter); | 306 | cgit_close_filter(ctx.cfg.about_filter); |
diff --git a/ui-snapshot.c b/ui-snapshot.c index 126779d..07cc944 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 | |||
| 19 | f.argv = malloc(2 * sizeof(char *)); | 19 | f.argv = malloc(2 * sizeof(char *)); |
| 20 | f.argv[0] = f.cmd; | 20 | f.argv[0] = f.cmd; |
| 21 | f.argv[1] = NULL; | 21 | f.argv[1] = NULL; |
| 22 | cgit_open_filter(&f, NULL); | 22 | cgit_open_filter(&f); |
| 23 | rv = write_tar_archive(args); | 23 | rv = write_tar_archive(args); |
| 24 | cgit_close_filter(&f); | 24 | cgit_close_filter(&f); |
| 25 | return rv; | 25 | return rv; |
diff --git a/ui-summary.c b/ui-summary.c index 1e9a1b6..5be2545 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
| @@ -113,7 +113,7 @@ void cgit_print_repo_readme(char *path) | |||
| 113 | */ | 113 | */ |
| 114 | html("<div id='summary'>"); | 114 | html("<div id='summary'>"); |
| 115 | if (ctx.repo->about_filter) | 115 | if (ctx.repo->about_filter) |
| 116 | cgit_open_filter(ctx.repo->about_filter, ctx.repo); | 116 | cgit_open_filter(ctx.repo->about_filter); |
| 117 | if (ref) | 117 | if (ref) |
| 118 | cgit_print_file(tmp, ref); | 118 | cgit_print_file(tmp, ref); |
| 119 | else | 119 | else |
| @@ -45,7 +45,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) | |||
| 45 | if (ctx.repo->source_filter) { | 45 | if (ctx.repo->source_filter) { |
| 46 | html("<td class='lines'><pre><code>"); | 46 | html("<td class='lines'><pre><code>"); |
| 47 | ctx.repo->source_filter->argv[1] = xstrdup(name); | 47 | ctx.repo->source_filter->argv[1] = xstrdup(name); |
| 48 | cgit_open_filter(ctx.repo->source_filter, ctx.repo); | 48 | cgit_open_filter(ctx.repo->source_filter); |
| 49 | html_raw(buf, size); | 49 | html_raw(buf, size); |
| 50 | cgit_close_filter(ctx.repo->source_filter); | 50 | cgit_close_filter(ctx.repo->source_filter); |
| 51 | free(ctx.repo->source_filter->argv[1]); | 51 | free(ctx.repo->source_filter->argv[1]); |
