Switch to exclusively using global ctx

Drop the context parameter from the following functions (and all static
helpers used by them) and use the global context instead:

* cgit_print_http_headers()
* cgit_print_docstart()
* cgit_print_pageheader()

Remove context parameter from all commands

Drop the context parameter from the following functions (and all static
helpers used by them) and use the global context instead:

* cgit_get_cmd()
* All cgit command functions.
* cgit_clone_info()
* cgit_clone_objects()
* cgit_clone_head()
* cgit_print_plain()
* cgit_show_stats()

In initialization routines, use the global context variable instead of
passing a pointer around locally.

Remove callback data parameter for cache slots

This is no longer needed since the context is always read from the
global context variable.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
此提交包含在:
Lukas Fleischer
2014-01-15 21:53:15 +01:00
提交者 Jason A. Donenfeld
父節點 a431326e8f
當前提交 f60ffa143c
共有 19 個檔案被更改,包括 436 行新增441 行删除

查看文件

@ -209,13 +209,12 @@ static int cmp_total_commits(const void *a1, const void *a2)
/* Walk the commit DAG and collect number of commits per author per
* timeperiod into a nested string_list collection.
*/
static struct string_list collect_stats(struct cgit_context *ctx,
struct cgit_period *period)
static struct string_list collect_stats(struct cgit_period *period)
{
struct string_list authors;
struct rev_info rev;
struct commit *commit;
const char *argv[] = {NULL, ctx->qry.head, NULL, NULL, NULL, NULL};
const char *argv[] = {NULL, ctx.qry.head, NULL, NULL, NULL, NULL};
int argc = 3;
time_t now;
long i;
@ -229,9 +228,9 @@ static struct string_list collect_stats(struct cgit_context *ctx,
period->dec(tm);
strftime(tmp, sizeof(tmp), "%Y-%m-%d", tm);
argv[2] = xstrdup(fmt("--since=%s", tmp));
if (ctx->qry.path) {
if (ctx.qry.path) {
argv[3] = "--";
argv[4] = ctx->qry.path;
argv[4] = ctx.qry.path;
argc += 2;
}
init_revisions(&rev, NULL);
@ -360,30 +359,30 @@ static void print_authors(struct string_list *authors, int top,
* for each author is another string_list which is used to calculate the
* number of commits per time-interval.
*/
void cgit_show_stats(struct cgit_context *ctx)
void cgit_show_stats(void)
{
struct string_list authors;
struct cgit_period *period;
int top, i;
const char *code = "w";
if (ctx->qry.period)
code = ctx->qry.period;
if (ctx.qry.period)
code = ctx.qry.period;
i = cgit_find_stats_period(code, &period);
if (!i) {
cgit_print_error("Unknown statistics type: %c", code[0]);
return;
}
if (i > ctx->repo->max_stats) {
if (i > ctx.repo->max_stats) {
cgit_print_error("Statistics type disabled: %s", period->name);
return;
}
authors = collect_stats(ctx, period);
authors = collect_stats(period);
qsort(authors.items, authors.nr, sizeof(struct string_list_item),
cmp_total_commits);
top = ctx->qry.ofs;
top = ctx.qry.ofs;
if (!top)
top = 10;
@ -392,10 +391,10 @@ void cgit_show_stats(struct cgit_context *ctx)
html("<form method='get' action=''>");
cgit_add_hidden_formfields(1, 0, "stats");
html("<table><tr><td colspan='2'/></tr>");
if (ctx->repo->max_stats > 1) {
if (ctx.repo->max_stats > 1) {
html("<tr><td class='label'>Period:</td>");
html("<td class='ctrl'><select name='period' onchange='this.form.submit();'>");
for (i = 0; i < ctx->repo->max_stats; i++)
for (i = 0; i < ctx.repo->max_stats; i++)
html_option(fmt("%c", periods[i].code),
periods[i].name, fmt("%c", period->code));
html("</select></td></tr>");
@ -414,9 +413,9 @@ void cgit_show_stats(struct cgit_context *ctx)
html("</form>");
html("</div>");
htmlf("<h2>Commits per author per %s", period->name);
if (ctx->qry.path) {
if (ctx.qry.path) {
html(" (path '");
html_txt(ctx->qry.path);
html_txt(ctx.qry.path);
html("')");
}
html("</h2>");