-rw-r--r-- | cgit.c | 4 | ||||
-rw-r--r-- | cgit.h | 20 | ||||
-rw-r--r-- | cgitrc.5.txt | 6 | ||||
-rw-r--r-- | shared.c | 2 | ||||
-rw-r--r-- | ui-commit.c | 16 | ||||
-rw-r--r-- | ui-tree.c | 8 |
6 files changed, 35 insertions, 21 deletions
@@ -145,8 +145,12 @@ void config_cb(const char *name, const char *value) | |||
145 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) | 145 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) |
146 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); | 146 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); |
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 == '/') |
151 | ctx.repo->readme = xstrdup(value); | 155 | ctx.repo->readme = xstrdup(value); |
152 | else | 156 | else |
@@ -47,8 +47,17 @@ | |||
47 | typedef void (*configfn)(const char *name, const char *value); | 47 | typedef void (*configfn)(const char *name, const char *value); |
48 | typedef void (*filepair_fn)(struct diff_filepair *pair); | 48 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
49 | typedef void (*linediff_fn)(char *line, int len); | 49 | typedef void (*linediff_fn)(char *line, int len); |
50 | 50 | ||
51 | struct 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 | |||
51 | struct cgit_repo { | 60 | struct cgit_repo { |
52 | char *url; | 61 | char *url; |
53 | char *name; | 62 | char *name; |
54 | char *path; | 63 | char *path; |
@@ -63,8 +72,10 @@ struct cgit_repo { | |||
63 | int enable_log_filecount; | 72 | int enable_log_filecount; |
64 | int enable_log_linecount; | 73 | int enable_log_linecount; |
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 | ||
69 | struct cgit_repolist { | 80 | struct cgit_repolist { |
70 | int length; | 81 | int length; |
@@ -128,17 +139,8 @@ struct cgit_query { | |||
128 | char *sort; | 139 | char *sort; |
129 | int showmsg; | 140 | int showmsg; |
130 | }; | 141 | }; |
131 | 142 | ||
132 | struct 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 | |||
141 | struct cgit_config { | 143 | struct cgit_config { |
142 | char *agefile; | 144 | char *agefile; |
143 | char *cache_root; | 145 | char *cache_root; |
144 | char *clone_prefix; | 146 | char *clone_prefix; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 2efd6aa..ffb3e0f 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -237,8 +237,11 @@ REPOSITORY SETTINGS | |||
237 | repo.clone-url:: | 237 | repo.clone-url:: |
238 | A list of space-separated urls which can be used to clone this repo. | 238 | A list of space-separated urls which can be used to clone this repo. |
239 | Default value: none. | 239 | Default value: none. |
240 | 240 | ||
241 | repo.commit-filter:: | ||
242 | Override the default commit-filter. Default value: <commit-filter>. | ||
243 | |||
241 | repo.defbranch:: | 244 | repo.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 |
243 | exists in the repository, the first branch name (when sorted) is used | 246 | exists in the repository, the first branch name (when sorted) is used |
244 | as default instead. Default value: "master". | 247 | as default instead. Default value: "master". |
@@ -277,8 +280,11 @@ repo.readme:: | |||
277 | repo.snapshots:: | 280 | repo.snapshots:: |
278 | A mask of allowed snapshot-formats for this repo, restricted by the | 281 | A mask of allowed snapshot-formats for this repo, restricted by the |
279 | "snapshots" global setting. Default value: <snapshots>. | 282 | "snapshots" global setting. Default value: <snapshots>. |
280 | 283 | ||
284 | repo.source-filter:: | ||
285 | Override the default source-filter. Default value: <source-filter>. | ||
286 | |||
281 | repo.url:: | 287 | repo.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 |
283 | setting specified for each repo. Default value: none. | 289 | setting specified for each repo. Default value: none. |
284 | 290 | ||
@@ -61,8 +61,10 @@ struct cgit_repo *cgit_add_repo(const char *url) | |||
61 | ret->max_stats = ctx.cfg.max_stats; | 61 | ret->max_stats = ctx.cfg.max_stats; |
62 | ret->module_link = ctx.cfg.module_link; | 62 | ret->module_link = ctx.cfg.module_link; |
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 | } |
67 | 69 | ||
68 | struct cgit_repo *cgit_get_repoinfo(const char *url) | 70 | struct cgit_repo *cgit_get_repoinfo(const char *url) |
diff --git a/ui-commit.c b/ui-commit.c index ee0e139..5815b58 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -88,21 +88,21 @@ void cgit_print_commit(char *hex) | |||
88 | html("</td></tr>"); | 88 | html("</td></tr>"); |
89 | } | 89 | } |
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) { |
107 | if (parents) | 107 | if (parents) |
108 | tmp = sha1_to_hex(commit->parents->item->object.sha1); | 108 | tmp = sha1_to_hex(commit->parents->item->object.sha1); |
@@ -21,14 +21,14 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) | |||
21 | const char *numberfmt = | 21 | const char *numberfmt = |
22 | "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; | 22 | "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; |
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; |
33 | } | 33 | } |
34 | 34 | ||