summaryrefslogtreecommitdiffabout
path: root/cgit.c
Side-by-side diff
Diffstat (limited to 'cgit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c86
1 files changed, 72 insertions, 14 deletions
diff --git a/cgit.c b/cgit.c
index ad62d10..96900bb 100644
--- a/cgit.c
+++ b/cgit.c
@@ -3,2 +3,3 @@
* Copyright (C) 2006 Lars Hjemli
+ * Copyright (C) 2010 Jason A. Donenfeld <Jason@zx2c4.com>
*
@@ -62,2 +63,6 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value)
repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
+ else if (!strcmp(name, "enable-remote-branches"))
+ repo->enable_remote_branches = atoi(value);
+ else if (!strcmp(name, "enable-subject-links"))
+ repo->enable_subject_links = atoi(value);
else if (!strcmp(name, "max-stats"))
@@ -69,6 +74,3 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value)
else if (!strcmp(name, "readme") && value != NULL) {
- if (*value == '/')
- repo->readme = xstrdup(value);
- else
- repo->readme = xstrdup(fmt("%s/%s", repo->path, value));
+ repo->readme = xstrdup(value);
} else if (ctx.cfg.enable_filter_overrides) {
@@ -93,2 +95,4 @@ void config_cb(const char *name, const char *value)
repo_config(ctx.repo, name + 5, value);
+ else if (!strcmp(name, "readme"))
+ ctx.cfg.readme = xstrdup(value);
else if (!strcmp(name, "root-title"))
@@ -133,2 +137,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.enable_filter_overrides = atoi(value);
+ else if (!strcmp(name, "enable-gitweb-owner"))
+ ctx.cfg.enable_gitweb_owner = atoi(value);
else if (!strcmp(name, "enable-index-links"))
@@ -139,2 +145,6 @@ void config_cb(const char *name, const char *value)
ctx.cfg.enable_log_linecount = atoi(value);
+ else if (!strcmp(name, "enable-remote-branches"))
+ ctx.cfg.enable_remote_branches = atoi(value);
+ else if (!strcmp(name, "enable-subject-links"))
+ ctx.cfg.enable_subject_links = atoi(value);
else if (!strcmp(name, "enable-tree-linenumbers"))
@@ -146,3 +156,3 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "cache-root"))
- ctx.cfg.cache_root = xstrdup(value);
+ ctx.cfg.cache_root = xstrdup(expand_macros(value));
else if (!strcmp(name, "cache-root-ttl"))
@@ -163,2 +173,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.embedded = atoi(value);
+ else if (!strcmp(name, "max-atom-items"))
+ ctx.cfg.max_atom_items = atoi(value);
else if (!strcmp(name, "max-message-length"))
@@ -167,2 +179,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.max_repodesc_len = atoi(value);
+ else if (!strcmp(name, "max-blob-size"))
+ ctx.cfg.max_blob_size = atoi(value);
else if (!strcmp(name, "max-repo-count"))
@@ -171,7 +185,14 @@ void config_cb(const char *name, const char *value)
ctx.cfg.max_commit_count = atoi(value);
+ else if (!strcmp(name, "project-list"))
+ ctx.cfg.project_list = xstrdup(expand_macros(value));
else if (!strcmp(name, "scan-path"))
if (!ctx.cfg.nocache && ctx.cfg.cache_size)
- process_cached_repolist(value);
+ process_cached_repolist(expand_macros(value));
+ else if (ctx.cfg.project_list)
+ scan_projects(expand_macros(value),
+ ctx.cfg.project_list, repo_config);
else
- scan_tree(value, repo_config);
+ scan_tree(expand_macros(value), repo_config);
+ else if (!strcmp(name, "section-from-path"))
+ ctx.cfg.section_from_path = atoi(value);
else if (!strcmp(name, "source-filter"))
@@ -184,2 +205,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.summary_tags = atoi(value);
+ else if (!strcmp(name, "side-by-side-diffs"))
+ ctx.cfg.ssdiff = atoi(value);
else if (!strcmp(name, "agefile"))
@@ -188,2 +211,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.renamelimit = atoi(value);
+ else if (!strcmp(name, "remove-suffix"))
+ ctx.cfg.remove_suffix = atoi(value);
else if (!strcmp(name, "robots"))
@@ -197,3 +222,3 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "include"))
- parse_configfile(value, config_cb);
+ parse_configfile(expand_macros(value), config_cb);
}
@@ -211,2 +236,4 @@ static void querystring_cb(const char *name, const char *value)
} else if (!strcmp(name, "url")) {
+ if (*value == '/')
+ value++;
ctx.qry.url = xstrdup(value);
@@ -240,2 +267,10 @@ static void querystring_cb(const char *name, const char *value)
ctx.qry.period = xstrdup(value);
+ } else if (!strcmp(name, "ss")) {
+ ctx.qry.ssdiff = atoi(value);
+ } else if (!strcmp(name, "all")) {
+ ctx.qry.show_all = atoi(value);
+ } else if (!strcmp(name, "context")) {
+ ctx.qry.context = atoi(value);
+ } else if (!strcmp(name, "ignorews")) {
+ ctx.qry.ignorews = atoi(value);
}
@@ -264,2 +299,3 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.local_time = 0;
+ ctx->cfg.enable_gitweb_owner = 1;
ctx->cfg.enable_tree_linenumbers = 1;
@@ -270,5 +306,8 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.max_repodesc_len = 80;
+ ctx->cfg.max_blob_size = 0;
ctx->cfg.max_stats = 0;
ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
+ ctx->cfg.project_list = NULL;
ctx->cfg.renamelimit = -1;
+ ctx->cfg.remove_suffix = 0;
ctx->cfg.robots = "index, nofollow";
@@ -281,2 +320,4 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.summary_tags = 10;
+ ctx->cfg.max_atom_items = 10;
+ ctx->cfg.ssdiff = 0;
ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG"));
@@ -412,2 +453,8 @@ static void process_request(void *cbdata)
+ /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual"
+ * in-project path limit to be made available at ctx->qry.vpath.
+ * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL).
+ */
+ ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL;
+
if (cmd->want_repo && !ctx->repo) {
@@ -543,3 +590,6 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
idx = cgit_repolist.count;
- scan_tree(path, repo_config);
+ if (ctx.cfg.project_list)
+ scan_projects(path, ctx.cfg.project_list, repo_config);
+ else
+ scan_tree(path, repo_config);
print_repolist(f, &cgit_repolist, idx);
@@ -557,5 +607,8 @@ static void process_cached_repolist(const char *path)
time_t age;
+ unsigned long hash;
- cached_rc = xstrdup(fmt("%s/rc-%8x", ctx.cfg.cache_root,
- hash_str(path)));
+ hash = hash_str(path);
+ if (ctx.cfg.project_list)
+ hash += hash_str(ctx.cfg.project_list);
+ cached_rc = xstrdup(fmt("%s/rc-%8lx", ctx.cfg.cache_root, hash));
@@ -566,4 +619,9 @@ static void process_cached_repolist(const char *path)
*/
- if (generate_cached_repolist(path, cached_rc))
- scan_tree(path, repo_config);
+ if (generate_cached_repolist(path, cached_rc)) {
+ if (ctx.cfg.project_list)
+ scan_projects(path, ctx.cfg.project_list,
+ repo_config);
+ else
+ scan_tree(path, repo_config);
+ }
return;
@@ -676,3 +734,3 @@ int main(int argc, const char **argv)
cgit_parse_args(argc, argv);
- parse_configfile(ctx.env.cgit_config, config_cb);
+ parse_configfile(expand_macros(ctx.env.cgit_config), config_cb);
ctx.repo = NULL;