From f60ffa143cca61e9729ac71033e1a556cf422871 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 15 Jan 2014 21:53:15 +0100 Subject: 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 --- ui-stats.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'ui-stats.c') diff --git a/ui-stats.c b/ui-stats.c index 84b247c..bc27308 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -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("
"); cgit_add_hidden_formfields(1, 0, "stats"); html(""); - if (ctx->repo->max_stats > 1) { + if (ctx.repo->max_stats > 1) { html(""); html(""); @@ -414,9 +413,9 @@ void cgit_show_stats(struct cgit_context *ctx) html(""); html(""); htmlf("

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("

"); -- cgit v1.2.3
Period: