summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2009-08-09 11:22:00 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2009-08-09 11:22:00 (UTC)
commite976df27952ca1e450c1c3d420532ac9f5e3036b (patch) (unidiff)
tree2634538f3144c935d1579315d4de289e6c890f19
parentf35db1cd2b75aac6952aa07713e44ca01fd89727 (diff)
downloadcgit-e976df27952ca1e450c1c3d420532ac9f5e3036b.zip
cgit-e976df27952ca1e450c1c3d420532ac9f5e3036b.tar.gz
cgit-e976df27952ca1e450c1c3d420532ac9f5e3036b.tar.bz2
Add support for repo.commit-filter and repo.source-filter
These options can be used to override the default commit- and source- filter settings per repository. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
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
@@ -148,2 +148,6 @@ void config_cb(const char *name, const char *value)
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) {
diff --git a/cgit.h b/cgit.h
index 438301d..f10ba05 100644
--- a/cgit.h
+++ b/cgit.h
@@ -50,2 +50,11 @@ typedef 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 {
@@ -66,2 +75,4 @@ struct cgit_repo {
66 time_t mtime; 75 time_t mtime;
76 struct cgit_filter *commit_filter;
77 struct cgit_filter *source_filter;
67}; 78};
@@ -131,11 +142,2 @@ struct cgit_query {
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 {
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 2efd6aa..ffb3e0f 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -240,2 +240,5 @@ repo.clone-url::
240 240
241repo.commit-filter::
242 Override the default commit-filter. Default value: <commit-filter>.
243
241repo.defbranch:: 244repo.defbranch::
@@ -280,2 +283,5 @@ repo.snapshots::
280 283
284repo.source-filter::
285 Override the default source-filter. Default value: <source-filter>.
286
281repo.url:: 287repo.url::
diff --git a/shared.c b/shared.c
index 288cfa2..783604b 100644
--- a/shared.c
+++ b/shared.c
@@ -64,2 +64,4 @@ struct cgit_repo *cgit_add_repo(const char *url)
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;
diff --git a/ui-commit.c b/ui-commit.c
index ee0e139..5815b58 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -91,7 +91,7 @@ void cgit_print_commit(char *hex)
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);
@@ -99,7 +99,7 @@ void cgit_print_commit(char *hex)
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>");
diff --git a/ui-tree.c b/ui-tree.c
index 816e121..caf6a9e 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -24,8 +24,8 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size)
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");