From: Lars Hjemli Date: Sat, 14 May 2011 18:00:33 +0000 (+0200) Subject: Merge branch 'dm/disable-clone' X-Git-Url: https://gitweb.ps.run/ps-cgit/commitdiff_plain/4837fddc35bbd8d6f66a40486f75cdee3197172d?hp=-c Merge branch 'dm/disable-clone' --- 4837fddc35bbd8d6f66a40486f75cdee3197172d diff --combined cgit.c index e302a7c,e0c2d9f..349d6e0 --- a/cgit.c +++ b/cgit.c @@@ -29,17 -29,15 +29,17 @@@ void add_mimetype(const char *name, con struct cgit_filter *new_filter(const char *cmd, int extra_args) { struct cgit_filter *f; + int args_size = 0; if (!cmd || !cmd[0]) return NULL; f = xmalloc(sizeof(struct cgit_filter)); f->cmd = xstrdup(cmd); - f->argv = xmalloc((2 + extra_args) * sizeof(char *)); + args_size = (2 + extra_args) * sizeof(char *); + f->argv = xmalloc(args_size); + memset(f->argv, 0, args_size); f->argv[0] = f->cmd; - f->argv[1] = NULL; return f; } @@@ -59,8 -57,6 +59,8 @@@ void repo_config(struct cgit_repo *repo repo->defbranch = xstrdup(value); else if (!strcmp(name, "snapshots")) repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); + else if (!strcmp(name, "enable-commit-graph")) + repo->enable_commit_graph = ctx.cfg.enable_commit_graph * atoi(value); else if (!strcmp(name, "enable-log-filecount")) repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); else if (!strcmp(name, "enable-log-linecount")) @@@ -75,13 -71,9 +75,13 @@@ repo->module_link= xstrdup(value); else if (!strcmp(name, "section")) repo->section = xstrdup(value); - else if (!strcmp(name, "readme") && value != NULL) { + else if (!strcmp(name, "readme") && value != NULL) repo->readme = xstrdup(value); - } else if (ctx.cfg.enable_filter_overrides) { + else if (!strcmp(name, "logo") && value != NULL) + repo->logo = xstrdup(value); + else if (!strcmp(name, "logo-link") && value != NULL) + repo->logo_link = xstrdup(value); + else if (ctx.cfg.enable_filter_overrides) { if (!strcmp(name, "about-filter")) repo->about_filter = new_filter(value, 0); else if (!strcmp(name, "commit-filter")) @@@ -147,10 -139,10 +147,12 @@@ void config_cb(const char *name, const 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-http-clone")) + ctx.cfg.enable_http_clone = atoi(value); else if (!strcmp(name, "enable-index-links")) ctx.cfg.enable_index_links = atoi(value); + else if (!strcmp(name, "enable-commit-graph")) + ctx.cfg.enable_commit_graph = atoi(value); else if (!strcmp(name, "enable-log-filecount")) ctx.cfg.enable_log_filecount = atoi(value); else if (!strcmp(name, "enable-log-linecount")) @@@ -205,8 -197,6 +207,8 @@@ ctx.cfg.project_list, repo_config); else scan_tree(expand_macros(value), repo_config); + else if (!strcmp(name, "scan-hidden-path")) + ctx.cfg.scan_hidden_path = atoi(value); else if (!strcmp(name, "section-from-path")) ctx.cfg.section_from_path = atoi(value); else if (!strcmp(name, "source-filter")) @@@ -312,6 -302,7 +314,7 @@@ static void prepare_context(struct cgit ctx->cfg.logo = "/cgit.png"; ctx->cfg.local_time = 0; ctx->cfg.enable_gitweb_owner = 1; + ctx->cfg.enable_http_clone = 1; ctx->cfg.enable_tree_linenumbers = 1; ctx->cfg.max_repo_count = 50; ctx->cfg.max_commit_count = 50; @@@ -327,7 -318,6 +330,7 @@@ ctx->cfg.robots = "index, nofollow"; ctx->cfg.root_title = "Git repository browser"; ctx->cfg.root_desc = "a fast webinterface for the git dscm"; + ctx->cfg.scan_hidden_path = 0; ctx->cfg.script_name = CGIT_SCRIPT_NAME; ctx->cfg.section = ""; ctx->cfg.summary_branches = 10; @@@ -439,7 -429,7 +442,7 @@@ static int prepare_repo_cmd(struct cgit tmp = xstrdup(ctx->qry.head); ctx->qry.head = ctx->repo->defbranch; ctx->page.status = 404; - ctx->page.statusmsg = "not found"; + ctx->page.statusmsg = "Not found"; cgit_print_http_headers(ctx); cgit_print_docstart(ctx); cgit_print_pageheader(ctx); @@@ -458,6 -448,8 +461,8 @@@ static void process_request(void *cbdat cmd = cgit_get_cmd(ctx); if (!cmd) { ctx->page.title = "cgit error"; + ctx->page.status = 404; + ctx->page.statusmsg = "Not found"; cgit_print_http_headers(ctx); cgit_print_docstart(ctx); cgit_print_pageheader(ctx); @@@ -466,6 -458,11 +471,11 @@@ return; } + if (!ctx->cfg.enable_http_clone && cmd->is_clone) { + html_status(404, "Not found", 0); + return; + } + /* 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). @@@ -553,8 -550,6 +563,8 @@@ void print_repo(FILE *f, struct cgit_re fprintf(f, "repo.section=%s\n", repo->section); if (repo->clone_url) fprintf(f, "repo.clone-url=%s\n", repo->clone_url); + fprintf(f, "repo.enable-commit-graph=%d\n", + repo->enable_commit_graph); fprintf(f, "repo.enable-log-filecount=%d\n", repo->enable_log_filecount); fprintf(f, "repo.enable-log-linecount=%d\n", @@@ -754,11 -749,10 +764,11 @@@ int main(int argc, const char **argv http_parse_querystring(ctx.qry.raw, querystring_cb); /* If virtual-root isn't specified in cgitrc, lets pretend - * that virtual-root equals SCRIPT_NAME. + * that virtual-root equals SCRIPT_NAME, minus any possibly + * trailing slashes. */ if (!ctx.cfg.virtual_root) - ctx.cfg.virtual_root = ctx.cfg.script_name; + ctx.cfg.virtual_root = trim_end(ctx.cfg.script_name, '/'); /* If no url parameter is specified on the querystring, lets * use PATH_INFO as url. This allows cgit to work with virtual diff --combined cgit.h index b5f00fc,c119712..ecae453 --- a/cgit.h +++ b/cgit.h @@@ -20,7 -20,6 +20,7 @@@ #include #include #include +#include /* @@@ -71,10 -70,7 +71,10 @@@ struct cgit_repo char *readme; char *section; char *clone_url; + char *logo; + char *logo_link; int snapshots; + int enable_commit_graph; int enable_log_filecount; int enable_log_linecount; int enable_remote_branches; @@@ -191,8 -187,8 +191,9 @@@ struct cgit_config int embedded; int enable_filter_overrides; int enable_gitweb_owner; + int enable_http_clone; int enable_index_links; + int enable_commit_graph; int enable_log_filecount; int enable_log_linecount; int enable_remote_branches; @@@ -212,7 -208,6 +213,7 @@@ int noheader; int renamelimit; int remove_suffix; + int scan_hidden_path; int section_from_path; int snapshots; int summary_branches; diff --combined cgitrc.5.txt index 65b210f,b8c69b8..875d51f --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@@ -90,12 -90,7 +90,12 @@@ embedded: Flag which, when set to "1", will make cgit generate a html fragment suitable for embedding in other html pages. Default value: none. See also: "noheader". - + +enable-commit-graph:: + Flag which, when set to "1", will make cgit print an ASCII-art commit + history graph to the left of the commit messages in the repository + log page. Default value: "0". + enable-filter-overrides:: Flag which, when set to "1", allows all filter settings to be overridden in repository-specific cgitrc files. Default value: none. @@@ -105,6 -100,11 +105,11 @@@ enable-gitweb-owner: for the git config value "gitweb.owner" to determine the owner. Default value: "1". See also: scan-path. + enable-http-clone:: + If set to "1", cgit will act as an dumb HTTP endpoint for git clones. + If you use an alternate way of serving git repositories, you may wish + to disable this. Default value: "1". + enable-index-links:: Flag which, when set to "1", will make cgit generate extra links for each repo in the repository index (specifically, to the "summary", @@@ -274,22 -274,13 +279,22 @@@ root-title: Text printed as heading on the repository index page. Default value: "Git Repository Browser". +scan-hidden-path:: + If set to "1" and scan-path is enabled, scan-path will recurse into + directories whose name starts with a period ('.'). Otherwise, + scan-path will stay away from such directories (considered as + "hidden"). Note that this does not apply to the ".git" directory in + non-bare repos. This must be defined prior to scan-path. + Default value: 0. See also: scan-path. + scan-path:: A path which will be scanned for repositories. If caching is enabled, the result will be cached as a cgitrc include-file in the cache directory. If project-list has been defined prior to scan-path, scan-path loads only the directories listed in the file pointed to by - project-list. Default value: none. See also: cache-scanrc-ttl, - project-list. + project-list. Be advised that only the global settings taken + before the scan-path directive will be applied to each repository. + Default value: none. See also: cache-scanrc-ttl, project-list. section:: The name of the current repository section - all repositories defined @@@ -309,8 -300,7 +314,8 @@@ side-by-side-diffs: snapshots:: Text which specifies the default set of snapshot formats generated by cgit. The value is a space-separated list of zero or more of the - values "tar", "tar.gz", "tar.bz2" and "zip". Default value: none. + values "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip". Default value: + none. source-filter:: Specifies a command which will be invoked to format plaintext blobs @@@ -369,10 -359,6 +374,10 @@@ repo.defbranch: repo.desc:: The value to show as repository description. Default value: none. +repo.enable-commit-graph:: + A flag which can be used to disable the global setting + `enable-commit-graph'. Default value: none. + repo.enable-log-filecount:: A flag which can be used to disable the global setting `enable-log-filecount'. Default value: none. @@@ -389,15 -375,6 +394,15 @@@ repo.enable-subject-links: A flag which can be used to override the global setting `enable-subject-links'. Default value: none. +repo.logo:: + Url which specifies the source of an image which will be used as a logo + on this repo's pages. Default value: global logo. + +repo.logo-link:: + Url loaded when clicking on the cgit logo image. If unspecified the + calculated url of the repository index page will be used. Default + value: global logo-link. + repo.max-stats:: Override the default maximum statistics period. Valid values are equal to the values specified for the global "max-stats" setting. Default @@@ -469,10 -446,6 +474,10 @@@ css=/css/cgit.cs enable-index-links=1 +# Enable ASCII art commit history graph on the log pages +enable-commit-graph=1 + + # Show number of affected files per commit on the log pages enable-log-filecount=1 diff --combined cmd.c index 536515b,0224ee9..d114eb3 --- a/cmd.c +++ b/cmd.c @@@ -67,8 -67,7 +67,8 @@@ static void info_fn(struct cgit_contex static void log_fn(struct cgit_context *ctx) { cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count, - ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1); + ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1, + ctx->repo->enable_commit_graph); } static void ls_cache_fn(struct cgit_context *ctx) @@@ -130,31 -129,31 +130,31 @@@ static void tree_fn(struct cgit_contex cgit_print_tree(ctx->qry.sha1, ctx->qry.path); } - #define def_cmd(name, want_repo, want_layout, want_vpath) \ - {#name, name##_fn, want_repo, want_layout, want_vpath} + #define def_cmd(name, want_repo, want_layout, want_vpath, is_clone) \ + {#name, name##_fn, want_repo, want_layout, want_vpath, is_clone} struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) { static struct cgit_cmd cmds[] = { - def_cmd(HEAD, 1, 0, 0), - def_cmd(atom, 1, 0, 0), - def_cmd(about, 0, 1, 0), - def_cmd(blob, 1, 0, 0), - def_cmd(commit, 1, 1, 1), - def_cmd(diff, 1, 1, 1), - def_cmd(info, 1, 0, 0), - def_cmd(log, 1, 1, 1), - def_cmd(ls_cache, 0, 0, 0), - def_cmd(objects, 1, 0, 0), - def_cmd(patch, 1, 0, 1), - def_cmd(plain, 1, 0, 0), - def_cmd(refs, 1, 1, 0), - def_cmd(repolist, 0, 0, 0), - def_cmd(snapshot, 1, 0, 0), - def_cmd(stats, 1, 1, 1), - def_cmd(summary, 1, 1, 0), - def_cmd(tag, 1, 1, 0), - def_cmd(tree, 1, 1, 1), + def_cmd(HEAD, 1, 0, 0, 1), + def_cmd(atom, 1, 0, 0, 0), + def_cmd(about, 0, 1, 0, 0), + def_cmd(blob, 1, 0, 0, 0), + def_cmd(commit, 1, 1, 1, 0), + def_cmd(diff, 1, 1, 1, 0), + def_cmd(info, 1, 0, 0, 1), + def_cmd(log, 1, 1, 1, 0), + def_cmd(ls_cache, 0, 0, 0, 0), + def_cmd(objects, 1, 0, 0, 1), + def_cmd(patch, 1, 0, 1, 0), + def_cmd(plain, 1, 0, 0, 0), + def_cmd(refs, 1, 1, 0, 0), + def_cmd(repolist, 0, 0, 0, 0), + def_cmd(snapshot, 1, 0, 0, 0), + def_cmd(stats, 1, 1, 1, 0), + def_cmd(summary, 1, 1, 0, 0), + def_cmd(tag, 1, 1, 0, 0), + def_cmd(tree, 1, 1, 1, 0), }; int i;