From 3516502aa0df95ecc241caa30161741f59e4e600 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 29 Jul 2010 17:52:29 +0200 Subject: Add support for 'project-list' option This option specifies the location of a projectlist file as used by gitweb - when 'scan-tree' is later specified, only the projects listed in the projectlist file will be added. Signed-off-by: Jason A. Donenfeld Signed-off-by: Lars Hjemli --- cgit.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'cgit.c') diff --git a/cgit.c b/cgit.c index c263872..2364d1c 100644 --- a/cgit.c +++ b/cgit.c @@ -181,9 +181,14 @@ void config_cb(const char *name, const char *value) ctx.cfg.max_repo_count = atoi(value); else if (!strcmp(name, "max-commit-count")) 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(expand_macros(value)); + else if (ctx.cfg.project_list) + scan_projects(expand_macros(value), + ctx.cfg.project_list, repo_config); else scan_tree(expand_macros(value), repo_config); else if (!strcmp(name, "source-filter")) @@ -295,6 +300,7 @@ static void prepare_context(struct cgit_context *ctx) 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.robots = "index, nofollow"; ctx->cfg.root_title = "Git repository browser"; @@ -574,7 +580,10 @@ static int generate_cached_repolist(const char *path, const char *cached_rc) return errno; } 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); if (rename(locked_rc, cached_rc)) fprintf(stderr, "[cgit] Error renaming %s to %s: %s (%d)\n", @@ -588,17 +597,25 @@ static void process_cached_repolist(const char *path) struct stat st; char *cached_rc; 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-%8x", ctx.cfg.cache_root, hash)); if (stat(cached_rc, &st)) { /* Nothing is cached, we need to scan without forking. And * if we fail to generate a cached repolist, we need to * invoke scan_tree manually. */ - 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; } -- cgit v1.2.1 From 2e4a941626c240bc7858aa7564882c01f657f4e8 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 29 Jul 2010 19:47:50 +0200 Subject: Add support for 'remove-suffix' option When this option is enabled, the '.git' suffix of repository directories found while processing the 'scan-path' option will be removed. Signed-off-by: Jason A. Donenfeld Signed-off-by: Lars Hjemli --- cgit.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cgit.c') diff --git a/cgit.c b/cgit.c index 2364d1c..f9a42bb 100644 --- a/cgit.c +++ b/cgit.c @@ -205,6 +205,8 @@ void config_cb(const char *name, const char *value) ctx.cfg.agefile = xstrdup(value); else if (!strcmp(name, "renamelimit")) ctx.cfg.renamelimit = atoi(value); + else if (!strcmp(name, "remove-suffix")) + ctx.cfg.remove_suffix = atoi(value); else if (!strcmp(name, "robots")) ctx.cfg.robots = xstrdup(value); else if (!strcmp(name, "clone-prefix")) @@ -302,6 +304,7 @@ static void prepare_context(struct cgit_context *ctx) 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"; ctx->cfg.root_title = "Git repository browser"; ctx->cfg.root_desc = "a fast webinterface for the git dscm"; -- cgit v1.2.1 From 119397b175874bd606952e93b7249ae4ffb9afbe Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 29 Jul 2010 20:38:01 +0200 Subject: Add support for 'enable-gitweb-owner' option When this option is enabled (which it is by default), cgit will lookup the 'gitweb.owner' setting in each git config file found when processing the 'scan-path' option. Signed-off-by: Jason A. Donenfeld Signed-off-by: Lars Hjemli --- cgit.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cgit.c') diff --git a/cgit.c b/cgit.c index f9a42bb..eff5b7a 100644 --- a/cgit.c +++ b/cgit.c @@ -135,6 +135,8 @@ void config_cb(const char *name, const char *value) ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); else if (!strcmp(name, "enable-filter-overrides")) 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")) ctx.cfg.enable_index_links = atoi(value); else if (!strcmp(name, "enable-log-filecount")) @@ -293,6 +295,7 @@ static void prepare_context(struct cgit_context *ctx) ctx->cfg.css = "/cgit.css"; ctx->cfg.logo = "/cgit.png"; ctx->cfg.local_time = 0; + ctx->cfg.enable_gitweb_owner = 1; ctx->cfg.enable_tree_linenumbers = 1; ctx->cfg.max_repo_count = 50; ctx->cfg.max_commit_count = 50; -- cgit v1.2.1