summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -137,24 +137,28 @@ void config_cb(const char *name, const char *value)
else if (ctx.repo && !strcmp(name, "repo.defbranch"))
ctx.repo->defbranch = xstrdup(value);
else if (ctx.repo && !strcmp(name, "repo.snapshots"))
ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount"))
ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))
ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
else if (ctx.repo && !strcmp(name, "repo.max-stats"))
ctx.repo->max_stats = cgit_find_stats_period(value, NULL);
else if (ctx.repo && !strcmp(name, "repo.module-link"))
ctx.repo->module_link= xstrdup(value);
+ else if (ctx.repo && !strcmp(name, "repo.commit-filter"))
+ ctx.repo->commit_filter = new_filter(value, 0);
+ else if (ctx.repo && !strcmp(name, "repo.source-filter"))
+ ctx.repo->source_filter = new_filter(value, 1);
else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
if (*value == '/')
ctx.repo->readme = xstrdup(value);
else
ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
} else if (!strcmp(name, "include"))
parse_configfile(value, config_cb);
}
static void querystring_cb(const char *name, const char *value)
{
if (!strcmp(name,"r")) {
diff --git a/cgit.h b/cgit.h
index 438301d..f10ba05 100644
--- a/cgit.h
+++ b/cgit.h
@@ -39,40 +39,51 @@
#define TM_MONTH (TM_YEAR / 12.0)
/*
* Default encoding
*/
#define PAGE_ENCODING "UTF-8"
typedef void (*configfn)(const char *name, const char *value);
typedef void (*filepair_fn)(struct diff_filepair *pair);
typedef void (*linediff_fn)(char *line, int len);
+struct cgit_filter {
+ char *cmd;
+ char **argv;
+ int old_stdout;
+ int pipe_fh[2];
+ int pid;
+ int exitstatus;
+};
+
struct cgit_repo {
char *url;
char *name;
char *path;
char *desc;
char *owner;
char *defbranch;
char *group;
char *module_link;
char *readme;
char *clone_url;
int snapshots;
int enable_log_filecount;
int enable_log_linecount;
int max_stats;
time_t mtime;
+ struct cgit_filter *commit_filter;
+ struct cgit_filter *source_filter;
};
struct cgit_repolist {
int length;
int count;
struct cgit_repo *repos;
};
struct commitinfo {
struct commit *commit;
char *author;
char *author_email;
@@ -120,33 +131,24 @@ struct cgit_query {
char *sha2;
char *path;
char *name;
char *mimetype;
char *url;
char *period;
int ofs;
int nohead;
char *sort;
int showmsg;
};
-struct cgit_filter {
- char *cmd;
- char **argv;
- int old_stdout;
- int pipe_fh[2];
- int pid;
- int exitstatus;
-};
-
struct cgit_config {
char *agefile;
char *cache_root;
char *clone_prefix;
char *css;
char *favicon;
char *footer;
char *head_include;
char *header;
char *index_header;
char *index_info;
char *logo;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 2efd6aa..ffb3e0f 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -229,24 +229,27 @@ virtual-root::
will also cause cgit to generate 'virtual urls', i.e. urls like
'/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default
value: none.
NOTE: cgit has recently learned how to use PATH_INFO to achieve the
same kind of virtual urls, so this option will probably be deprecated.
REPOSITORY SETTINGS
-------------------
repo.clone-url::
A list of space-separated urls which can be used to clone this repo.
Default value: none.
+repo.commit-filter::
+ Override the default commit-filter. Default value: <commit-filter>.
+
repo.defbranch::
The name of the default branch for this repository. If no such branch
exists in the repository, the first branch name (when sorted) is used
as default instead. Default value: "master".
repo.desc::
The value to show as repository description. Default value: none.
repo.enable-log-filecount::
A flag which can be used to disable the global setting
`enable-log-filecount'. Default value: none.
@@ -269,24 +272,27 @@ repo.owner::
repo.path::
An absolute path to the repository directory. For non-bare repositories
this is the .git-directory. Default value: none.
repo.readme::
A path (relative to <repo.path>) which specifies a file to include
verbatim as the "About" page for this repo. Default value: none.
repo.snapshots::
A mask of allowed snapshot-formats for this repo, restricted by the
"snapshots" global setting. Default value: <snapshots>.
+repo.source-filter::
+ Override the default source-filter. Default value: <source-filter>.
+
repo.url::
The relative url used to access the repository. This must be the first
setting specified for each repo. Default value: none.
EXAMPLE CGITRC FILE
-------------------
....
# Enable caching of up to 1000 output entriess
cache-size=1000
diff --git a/shared.c b/shared.c
index 288cfa2..783604b 100644
--- a/shared.c
+++ b/shared.c
@@ -53,24 +53,26 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->path = NULL;
ret->desc = "[no description]";
ret->owner = NULL;
ret->group = ctx.cfg.repo_group;
ret->defbranch = "master";
ret->snapshots = ctx.cfg.snapshots;
ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
ret->enable_log_linecount = ctx.cfg.enable_log_linecount;
ret->max_stats = ctx.cfg.max_stats;
ret->module_link = ctx.cfg.module_link;
ret->readme = NULL;
ret->mtime = -1;
+ ret->commit_filter = ctx.cfg.commit_filter;
+ ret->source_filter = ctx.cfg.source_filter;
return ret;
}
struct cgit_repo *cgit_get_repoinfo(const char *url)
{
int i;
struct cgit_repo *repo;
for (i=0; i<cgit_repolist.count; i++) {
repo = &cgit_repolist.repos[i];
if (!strcmp(repo->url, url))
return repo;
diff --git a/ui-commit.c b/ui-commit.c
index ee0e139..5815b58 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -80,35 +80,35 @@ void cgit_print_commit(char *hex)
sha1_to_hex(p->item->object.sha1), NULL);
html(")</td></tr>");
parents++;
}
if (ctx.repo->snapshots) {
html("<tr><th>download</th><td colspan='2' class='sha1'>");
cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
hex, ctx.repo->snapshots);
html("</td></tr>");
}
html("</table>\n");
html("<div class='commit-subject'>");
- if (ctx.cfg.commit_filter)
- cgit_open_filter(ctx.cfg.commit_filter);
+ if (ctx.repo->commit_filter)
+ cgit_open_filter(ctx.repo->commit_filter);
html_txt(info->subject);
- if (ctx.cfg.commit_filter)
- cgit_close_filter(ctx.cfg.commit_filter);
+ if (ctx.repo->commit_filter)
+ cgit_close_filter(ctx.repo->commit_filter);
show_commit_decorations(commit);
html("</div>");
html("<div class='commit-msg'>");
- if (ctx.cfg.commit_filter)
- cgit_open_filter(ctx.cfg.commit_filter);
+ if (ctx.repo->commit_filter)
+ cgit_open_filter(ctx.repo->commit_filter);
html_txt(info->msg);
- if (ctx.cfg.commit_filter)
- cgit_close_filter(ctx.cfg.commit_filter);
+ if (ctx.repo->commit_filter)
+ cgit_close_filter(ctx.repo->commit_filter);
html("</div>");
if (parents < 3) {
if (parents)
tmp = sha1_to_hex(commit->parents->item->object.sha1);
else
tmp = NULL;
cgit_print_diff(ctx.qry.sha1, tmp, NULL);
}
cgit_free_commitinfo(info);
}
diff --git a/ui-tree.c b/ui-tree.c
index 816e121..caf6a9e 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -13,30 +13,30 @@
char *curr_rev;
char *match_path;
int header = 0;
static void print_text_buffer(const char *name, char *buf, unsigned long size)
{
unsigned long lineno, idx;
const char *numberfmt =
"<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n";
html("<table summary='blob content' class='blob'>\n");
- if (ctx.cfg.source_filter) {
+ if (ctx.repo->source_filter) {
html("<tr><td class='lines'><pre><code>");
- ctx.cfg.source_filter->argv[1] = xstrdup(name);
- cgit_open_filter(ctx.cfg.source_filter);
+ ctx.repo->source_filter->argv[1] = xstrdup(name);
+ cgit_open_filter(ctx.repo->source_filter);
write(STDOUT_FILENO, buf, size);
- cgit_close_filter(ctx.cfg.source_filter);
+ cgit_close_filter(ctx.repo->source_filter);
html("</code></pre></td></tr></table>\n");
return;
}
html("<tr><td class='linenumbers'><pre>");
idx = 0;
lineno = 0;
if (size) {
htmlf(numberfmt, ++lineno);
while(idx < size - 1) { // skip absolute last newline
if (buf[idx] == '\n')