summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c4
-rw-r--r--cgit.h20
-rw-r--r--cgitrc.5.txt6
-rw-r--r--shared.c2
-rw-r--r--ui-commit.c16
-rw-r--r--ui-tree.c8
6 files changed, 35 insertions, 21 deletions
diff --git a/cgit.c b/cgit.c
index 2cda554..fd341b8 100644
--- a/cgit.c
+++ b/cgit.c
@@ -147,4 +147,8 @@ void config_cb(const char *name, const char *value)
147 else if (ctx.repo && !strcmp(name, "repo.module-link")) 147 else if (ctx.repo && !strcmp(name, "repo.module-link"))
148 ctx.repo->module_link= xstrdup(value); 148 ctx.repo->module_link= xstrdup(value);
149 else if (ctx.repo && !strcmp(name, "repo.commit-filter"))
150 ctx.repo->commit_filter = new_filter(value, 0);
151 else if (ctx.repo && !strcmp(name, "repo.source-filter"))
152 ctx.repo->source_filter = new_filter(value, 1);
149 else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { 153 else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
150 if (*value == '/') 154 if (*value == '/')
diff --git a/cgit.h b/cgit.h
index 438301d..f10ba05 100644
--- a/cgit.h
+++ b/cgit.h
@@ -49,4 +49,13 @@ typedef void (*filepair_fn)(struct diff_filepair *pair);
49typedef void (*linediff_fn)(char *line, int len); 49typedef void (*linediff_fn)(char *line, int len);
50 50
51struct cgit_filter {
52 char *cmd;
53 char **argv;
54 int old_stdout;
55 int pipe_fh[2];
56 int pid;
57 int exitstatus;
58};
59
51struct cgit_repo { 60struct cgit_repo {
52 char *url; 61 char *url;
@@ -65,4 +74,6 @@ struct cgit_repo {
65 int max_stats; 74 int max_stats;
66 time_t mtime; 75 time_t mtime;
76 struct cgit_filter *commit_filter;
77 struct cgit_filter *source_filter;
67}; 78};
68 79
@@ -130,13 +141,4 @@ struct cgit_query {
130}; 141};
131 142
132struct cgit_filter {
133 char *cmd;
134 char **argv;
135 int old_stdout;
136 int pipe_fh[2];
137 int pid;
138 int exitstatus;
139};
140
141struct cgit_config { 143struct cgit_config {
142 char *agefile; 144 char *agefile;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 2efd6aa..ffb3e0f 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -239,4 +239,7 @@ repo.clone-url::
239 Default value: none. 239 Default value: none.
240 240
241repo.commit-filter::
242 Override the default commit-filter. Default value: <commit-filter>.
243
241repo.defbranch:: 244repo.defbranch::
242 The name of the default branch for this repository. If no such branch 245 The name of the default branch for this repository. If no such branch
@@ -279,4 +282,7 @@ repo.snapshots::
279 "snapshots" global setting. Default value: <snapshots>. 282 "snapshots" global setting. Default value: <snapshots>.
280 283
284repo.source-filter::
285 Override the default source-filter. Default value: <source-filter>.
286
281repo.url:: 287repo.url::
282 The relative url used to access the repository. This must be the first 288 The relative url used to access the repository. This must be the first
diff --git a/shared.c b/shared.c
index 288cfa2..783604b 100644
--- a/shared.c
+++ b/shared.c
@@ -63,4 +63,6 @@ struct cgit_repo *cgit_add_repo(const char *url)
63 ret->readme = NULL; 63 ret->readme = NULL;
64 ret->mtime = -1; 64 ret->mtime = -1;
65 ret->commit_filter = ctx.cfg.commit_filter;
66 ret->source_filter = ctx.cfg.source_filter;
65 return ret; 67 return ret;
66} 68}
diff --git a/ui-commit.c b/ui-commit.c
index ee0e139..5815b58 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -90,17 +90,17 @@ void cgit_print_commit(char *hex)
90 html("</table>\n"); 90 html("</table>\n");
91 html("<div class='commit-subject'>"); 91 html("<div class='commit-subject'>");
92 if (ctx.cfg.commit_filter) 92 if (ctx.repo->commit_filter)
93 cgit_open_filter(ctx.cfg.commit_filter); 93 cgit_open_filter(ctx.repo->commit_filter);
94 html_txt(info->subject); 94 html_txt(info->subject);
95 if (ctx.cfg.commit_filter) 95 if (ctx.repo->commit_filter)
96 cgit_close_filter(ctx.cfg.commit_filter); 96 cgit_close_filter(ctx.repo->commit_filter);
97 show_commit_decorations(commit); 97 show_commit_decorations(commit);
98 html("</div>"); 98 html("</div>");
99 html("<div class='commit-msg'>"); 99 html("<div class='commit-msg'>");
100 if (ctx.cfg.commit_filter) 100 if (ctx.repo->commit_filter)
101 cgit_open_filter(ctx.cfg.commit_filter); 101 cgit_open_filter(ctx.repo->commit_filter);
102 html_txt(info->msg); 102 html_txt(info->msg);
103 if (ctx.cfg.commit_filter) 103 if (ctx.repo->commit_filter)
104 cgit_close_filter(ctx.cfg.commit_filter); 104 cgit_close_filter(ctx.repo->commit_filter);
105 html("</div>"); 105 html("</div>");
106 if (parents < 3) { 106 if (parents < 3) {
diff --git a/ui-tree.c b/ui-tree.c
index 816e121..caf6a9e 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -23,10 +23,10 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size)
23 23
24 html("<table summary='blob content' class='blob'>\n"); 24 html("<table summary='blob content' class='blob'>\n");
25 if (ctx.cfg.source_filter) { 25 if (ctx.repo->source_filter) {
26 html("<tr><td class='lines'><pre><code>"); 26 html("<tr><td class='lines'><pre><code>");
27 ctx.cfg.source_filter->argv[1] = xstrdup(name); 27 ctx.repo->source_filter->argv[1] = xstrdup(name);
28 cgit_open_filter(ctx.cfg.source_filter); 28 cgit_open_filter(ctx.repo->source_filter);
29 write(STDOUT_FILENO, buf, size); 29 write(STDOUT_FILENO, buf, size);
30 cgit_close_filter(ctx.cfg.source_filter); 30 cgit_close_filter(ctx.repo->source_filter);
31 html("</code></pre></td></tr></table>\n"); 31 html("</code></pre></td></tr></table>\n");
32 return; 32 return;