mirror of
https://git.zx2c4.com/cgit
synced 2024-11-22 08:28:42 +00:00
ui-tree: allow per repository override for enable-blame
The blame operation can cause high cost in terms of CPU load for huge repositories. Let's add a per repository override for enable-blame. Signed-off-by: Christian Hesse <mail@eworm.de>
This commit is contained in:
parent
27a6d69ab3
commit
e1ad15d368
4
cgit.c
4
cgit.c
@ -50,6 +50,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
|
|||||||
repo->extra_head_content = xstrdup(value);
|
repo->extra_head_content = xstrdup(value);
|
||||||
else if (!strcmp(name, "snapshots"))
|
else if (!strcmp(name, "snapshots"))
|
||||||
repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
|
repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
|
||||||
|
else if (!strcmp(name, "enable-blame"))
|
||||||
|
repo->enable_blame = atoi(value);
|
||||||
else if (!strcmp(name, "enable-commit-graph"))
|
else if (!strcmp(name, "enable-commit-graph"))
|
||||||
repo->enable_commit_graph = atoi(value);
|
repo->enable_commit_graph = atoi(value);
|
||||||
else if (!strcmp(name, "enable-log-filecount"))
|
else if (!strcmp(name, "enable-log-filecount"))
|
||||||
@ -809,6 +811,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
|
|||||||
fprintf(f, "repo.homepage=%s\n", repo->homepage);
|
fprintf(f, "repo.homepage=%s\n", repo->homepage);
|
||||||
if (repo->clone_url)
|
if (repo->clone_url)
|
||||||
fprintf(f, "repo.clone-url=%s\n", repo->clone_url);
|
fprintf(f, "repo.clone-url=%s\n", repo->clone_url);
|
||||||
|
fprintf(f, "repo.enable-blame=%d\n",
|
||||||
|
repo->enable_blame);
|
||||||
fprintf(f, "repo.enable-commit-graph=%d\n",
|
fprintf(f, "repo.enable-commit-graph=%d\n",
|
||||||
repo->enable_commit_graph);
|
repo->enable_commit_graph);
|
||||||
fprintf(f, "repo.enable-log-filecount=%d\n",
|
fprintf(f, "repo.enable-log-filecount=%d\n",
|
||||||
|
1
cgit.h
1
cgit.h
@ -94,6 +94,7 @@ struct cgit_repo {
|
|||||||
char *logo_link;
|
char *logo_link;
|
||||||
char *snapshot_prefix;
|
char *snapshot_prefix;
|
||||||
int snapshots;
|
int snapshots;
|
||||||
|
int enable_blame;
|
||||||
int enable_commit_graph;
|
int enable_commit_graph;
|
||||||
int enable_log_filecount;
|
int enable_log_filecount;
|
||||||
int enable_log_linecount;
|
int enable_log_linecount;
|
||||||
|
@ -485,6 +485,10 @@ repo.email-filter::
|
|||||||
Override the default email-filter. Default value: none. See also:
|
Override the default email-filter. Default value: none. See also:
|
||||||
"enable-filter-overrides". See also: "FILTER API".
|
"enable-filter-overrides". See also: "FILTER API".
|
||||||
|
|
||||||
|
repo.enable-blame::
|
||||||
|
A flag which can be used to disable the global setting
|
||||||
|
`enable-blame'. Default value: none.
|
||||||
|
|
||||||
repo.enable-commit-graph::
|
repo.enable-commit-graph::
|
||||||
A flag which can be used to disable the global setting
|
A flag which can be used to disable the global setting
|
||||||
`enable-commit-graph'. Default value: none.
|
`enable-commit-graph'. Default value: none.
|
||||||
|
2
cmd.c
2
cmd.c
@ -66,7 +66,7 @@ static void about_fn(void)
|
|||||||
|
|
||||||
static void blame_fn(void)
|
static void blame_fn(void)
|
||||||
{
|
{
|
||||||
if (ctx.cfg.enable_blame)
|
if (ctx.repo->enable_blame)
|
||||||
cgit_print_blame();
|
cgit_print_blame();
|
||||||
else
|
else
|
||||||
cgit_print_error_page(403, "Forbidden", "Blame is disabled");
|
cgit_print_error_page(403, "Forbidden", "Blame is disabled");
|
||||||
|
1
shared.c
1
shared.c
@ -58,6 +58,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
|
|||||||
ret->homepage = NULL;
|
ret->homepage = NULL;
|
||||||
ret->section = ctx.cfg.section;
|
ret->section = ctx.cfg.section;
|
||||||
ret->snapshots = ctx.cfg.snapshots;
|
ret->snapshots = ctx.cfg.snapshots;
|
||||||
|
ret->enable_blame = ctx.cfg.enable_blame;
|
||||||
ret->enable_commit_graph = ctx.cfg.enable_commit_graph;
|
ret->enable_commit_graph = ctx.cfg.enable_commit_graph;
|
||||||
ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
|
ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
|
||||||
ret->enable_log_linecount = ctx.cfg.enable_log_linecount;
|
ret->enable_log_linecount = ctx.cfg.enable_log_linecount;
|
||||||
|
@ -110,7 +110,7 @@ static void print_object(const struct object_id *oid, const char *path, const ch
|
|||||||
htmlf("blob: %s (", oid_to_hex(oid));
|
htmlf("blob: %s (", oid_to_hex(oid));
|
||||||
cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
|
cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
|
||||||
rev, path);
|
rev, path);
|
||||||
if (ctx.cfg.enable_blame) {
|
if (ctx.repo->enable_blame) {
|
||||||
html(") (");
|
html(") (");
|
||||||
cgit_blame_link("blame", NULL, NULL, ctx.qry.head,
|
cgit_blame_link("blame", NULL, NULL, ctx.qry.head,
|
||||||
rev, path);
|
rev, path);
|
||||||
@ -251,7 +251,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,
|
|||||||
if (!S_ISGITLINK(mode))
|
if (!S_ISGITLINK(mode))
|
||||||
cgit_plain_link("plain", NULL, "button", ctx.qry.head,
|
cgit_plain_link("plain", NULL, "button", ctx.qry.head,
|
||||||
walk_tree_ctx->curr_rev, fullpath.buf);
|
walk_tree_ctx->curr_rev, fullpath.buf);
|
||||||
if (!S_ISDIR(mode) && ctx.cfg.enable_blame)
|
if (!S_ISDIR(mode) && ctx.repo->enable_blame)
|
||||||
cgit_blame_link("blame", NULL, "button", ctx.qry.head,
|
cgit_blame_link("blame", NULL, "button", ctx.qry.head,
|
||||||
walk_tree_ctx->curr_rev, fullpath.buf);
|
walk_tree_ctx->curr_rev, fullpath.buf);
|
||||||
html("</td></tr>\n");
|
html("</td></tr>\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user