diff options
| -rw-r--r-- | cgit.c | 23 | ||||
| -rw-r--r-- | cgit.h | 16 | ||||
| -rw-r--r-- | cgitrc.5.txt | 20 | ||||
| -rw-r--r-- | shared.c | 37 | ||||
| -rw-r--r-- | ui-commit.c | 8 | ||||
| -rw-r--r-- | ui-snapshot.c | 35 | ||||
| -rw-r--r-- | ui-tree.c | 18 |
7 files changed, 125 insertions, 32 deletions
| @@ -25,6 +25,21 @@ void add_mimetype(const char *name, const char *value) | |||
| 25 | item->util = xstrdup(value); | 25 | item->util = xstrdup(value); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | ||
| 29 | { | ||
| 30 | struct cgit_filter *f; | ||
| 31 | |||
| 32 | if (!cmd || !cmd[0]) | ||
| 33 | return NULL; | ||
| 34 | |||
| 35 | f = xmalloc(sizeof(struct cgit_filter)); | ||
| 36 | f->cmd = xstrdup(cmd); | ||
| 37 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); | ||
| 38 | f->argv[0] = f->cmd; | ||
| 39 | f->argv[1] = NULL; | ||
| 40 | return f; | ||
| 41 | } | ||
| 42 | |||
| 28 | void config_cb(const char *name, const char *value) | 43 | void config_cb(const char *name, const char *value) |
| 29 | { | 44 | { |
| 30 | if (!strcmp(name, "root-title")) | 45 | if (!strcmp(name, "root-title")) |
| @@ -85,6 +100,8 @@ void config_cb(const char *name, const char *value) | |||
| 85 | ctx.cfg.cache_static_ttl = atoi(value); | 100 | ctx.cfg.cache_static_ttl = atoi(value); |
| 86 | else if (!strcmp(name, "cache-dynamic-ttl")) | 101 | else if (!strcmp(name, "cache-dynamic-ttl")) |
| 87 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 102 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
| 103 | else if (!strcmp(name, "commit-filter")) | ||
| 104 | ctx.cfg.commit_filter = new_filter(value, 0); | ||
| 88 | else if (!strcmp(name, "embedded")) | 105 | else if (!strcmp(name, "embedded")) |
| 89 | ctx.cfg.embedded = atoi(value); | 106 | ctx.cfg.embedded = atoi(value); |
| 90 | else if (!strcmp(name, "max-message-length")) | 107 | else if (!strcmp(name, "max-message-length")) |
| @@ -95,6 +112,8 @@ void config_cb(const char *name, const char *value) | |||
| 95 | ctx.cfg.max_repo_count = atoi(value); | 112 | ctx.cfg.max_repo_count = atoi(value); |
| 96 | else if (!strcmp(name, "max-commit-count")) | 113 | else if (!strcmp(name, "max-commit-count")) |
| 97 | ctx.cfg.max_commit_count = atoi(value); | 114 | ctx.cfg.max_commit_count = atoi(value); |
| 115 | else if (!strcmp(name, "source-filter")) | ||
| 116 | ctx.cfg.source_filter = new_filter(value, 1); | ||
| 98 | else if (!strcmp(name, "summary-log")) | 117 | else if (!strcmp(name, "summary-log")) |
| 99 | ctx.cfg.summary_log = atoi(value); | 118 | ctx.cfg.summary_log = atoi(value); |
| 100 | else if (!strcmp(name, "summary-branches")) | 119 | else if (!strcmp(name, "summary-branches")) |
| @@ -139,6 +158,10 @@ void config_cb(const char *name, const char *value) | |||
| 139 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); | 158 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); |
| 140 | else if (ctx.repo && !strcmp(name, "repo.module-link")) | 159 | else if (ctx.repo && !strcmp(name, "repo.module-link")) |
| 141 | ctx.repo->module_link= xstrdup(value); | 160 | ctx.repo->module_link= xstrdup(value); |
| 161 | else if (ctx.repo && !strcmp(name, "repo.commit-filter")) | ||
| 162 | ctx.repo->commit_filter = new_filter(value, 0); | ||
| 163 | else if (ctx.repo && !strcmp(name, "repo.source-filter")) | ||
| 164 | ctx.repo->source_filter = new_filter(value, 1); | ||
| 142 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { | 165 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { |
| 143 | if (*value == '/') | 166 | if (*value == '/') |
| 144 | ctx.repo->readme = xstrdup(value); | 167 | ctx.repo->readme = xstrdup(value); |
| @@ -49,6 +49,15 @@ typedef void (*configfn)(const char *name, const char *value); | |||
| 49 | typedef void (*filepair_fn)(struct diff_filepair *pair); | 49 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
| 50 | typedef void (*linediff_fn)(char *line, int len); | 50 | typedef void (*linediff_fn)(char *line, int len); |
| 51 | 51 | ||
| 52 | struct cgit_filter { | ||
| 53 | char *cmd; | ||
| 54 | char **argv; | ||
| 55 | int old_stdout; | ||
| 56 | int pipe_fh[2]; | ||
| 57 | int pid; | ||
| 58 | int exitstatus; | ||
| 59 | }; | ||
| 60 | |||
| 52 | struct cgit_repo { | 61 | struct cgit_repo { |
| 53 | char *url; | 62 | char *url; |
| 54 | char *name; | 63 | char *name; |
| @@ -65,6 +74,8 @@ struct cgit_repo { | |||
| 65 | int enable_log_linecount; | 74 | int enable_log_linecount; |
| 66 | int max_stats; | 75 | int max_stats; |
| 67 | time_t mtime; | 76 | time_t mtime; |
| 77 | struct cgit_filter *commit_filter; | ||
| 78 | struct cgit_filter *source_filter; | ||
| 68 | }; | 79 | }; |
| 69 | 80 | ||
| 70 | struct cgit_repolist { | 81 | struct cgit_repolist { |
| @@ -177,6 +188,8 @@ struct cgit_config { | |||
| 177 | int summary_log; | 188 | int summary_log; |
| 178 | int summary_tags; | 189 | int summary_tags; |
| 179 | struct string_list mimetypes; | 190 | struct string_list mimetypes; |
| 191 | struct cgit_filter *commit_filter; | ||
| 192 | struct cgit_filter *source_filter; | ||
| 180 | }; | 193 | }; |
| 181 | 194 | ||
| 182 | struct cgit_page { | 195 | struct cgit_page { |
| @@ -251,5 +264,8 @@ extern const char *cgit_repobasename(const char *reponame); | |||
| 251 | 264 | ||
| 252 | extern int cgit_parse_snapshots_mask(const char *str); | 265 | extern int cgit_parse_snapshots_mask(const char *str); |
| 253 | 266 | ||
| 267 | extern int cgit_open_filter(struct cgit_filter *filter); | ||
| 268 | extern int cgit_close_filter(struct cgit_filter *filter); | ||
| 269 | |||
| 254 | 270 | ||
| 255 | #endif /* CGIT_H */ | 271 | #endif /* CGIT_H */ |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 0412f64..dc63637 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
| @@ -55,6 +55,12 @@ clone-prefix:: | |||
| 55 | setting is only used if `repo.clone-url` is unspecified. Default value: | 55 | setting is only used if `repo.clone-url` is unspecified. Default value: |
| 56 | none. | 56 | none. |
| 57 | 57 | ||
| 58 | commit-filter:: | ||
| 59 | Specifies a command which will be invoked to format commit messages. | ||
| 60 | The command will get the message on its STDIN, and the STDOUT from the | ||
| 61 | command will be included verbatim as the commit message, i.e. this can | ||
| 62 | be used to implement bugtracker integration. Default value: none. | ||
| 63 | |||
| 58 | css:: | 64 | css:: |
| 59 | Url which specifies the css document to include in all cgit pages. | 65 | Url which specifies the css document to include in all cgit pages. |
| 60 | Default value: "/cgit.css". | 66 | Default value: "/cgit.css". |
| @@ -206,6 +212,14 @@ snapshots:: | |||
| 206 | "zip" zip-file | 212 | "zip" zip-file |
| 207 | Default value: none. | 213 | Default value: none. |
| 208 | 214 | ||
| 215 | source-filter:: | ||
| 216 | Specifies a command which will be invoked to format plaintext blobs | ||
| 217 | in the tree view. The command will get the blob content on its STDIN | ||
| 218 | and the name of the blob as its only command line argument. The STDOUT | ||
| 219 | from the command will be included verbatim as the blob contents, i.e. | ||
| 220 | this can be used to implement e.g. syntax highlighting. Default value: | ||
| 221 | none. | ||
| 222 | |||
| 209 | summary-branches:: | 223 | summary-branches:: |
| 210 | Specifies the number of branches to display in the repository "summary" | 224 | Specifies the number of branches to display in the repository "summary" |
| 211 | view. Default value: "10". | 225 | view. Default value: "10". |
| @@ -232,6 +246,9 @@ repo.clone-url:: | |||
| 232 | A list of space-separated urls which can be used to clone this repo. | 246 | A list of space-separated urls which can be used to clone this repo. |
| 233 | Default value: none. | 247 | Default value: none. |
| 234 | 248 | ||
| 249 | repo.commit-filter:: | ||
| 250 | Override the default commit-filter. Default value: <commit-filter>. | ||
| 251 | |||
| 235 | repo.defbranch:: | 252 | repo.defbranch:: |
| 236 | The name of the default branch for this repository. If no such branch | 253 | The name of the default branch for this repository. If no such branch |
| 237 | exists in the repository, the first branch name (when sorted) is used | 254 | exists in the repository, the first branch name (when sorted) is used |
| @@ -272,6 +289,9 @@ repo.snapshots:: | |||
| 272 | A mask of allowed snapshot-formats for this repo, restricted by the | 289 | A mask of allowed snapshot-formats for this repo, restricted by the |
