diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Stop the stats page after its error page
A walk that failed to prepare printed an error page and then went on
to print the statistics page after it, where the log and the feed
return. No request reaches that failure today, since the walk is only
limited by a range or an order the page never asks for.
Diffstat (limited to '')
| -rw-r--r-- | source/ui-stats.c | 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 12 insertions, 11 deletions
diff --git a/source/ui-stats.c b/source/ui-stats.c index 55ed370..f200b63 100644 --- a/source/ui-stats.c +++ b/source/ui-stats.c @@ -202,13 +202,13 @@ static void add_commit(struct string_list *authors, struct commitinfo *info, } /* - * Count the commits in the displayed window, returning a list of authors - * whose util field holds a struct authorstat. Merge commits are left out, so - * that pulling a branch in does not credit the merger with its commits. + * Count the commits in the displayed window into authors, whose util fields + * hold a struct authorstat, and return non-zero once an error page has + * answered instead. Merge commits are left out, so that pulling a branch in + * does not credit the merger with its commits. */ -static struct string_list collect_stats(const struct cgit_period *period) +static int collect_stats(const struct cgit_period *period, struct string_list *authors) { - struct string_list authors; struct rev_info rev; struct commit *commit; // setup_revisions reads these the way main does, skipping the first @@ -239,24 +239,23 @@ static struct string_list collect_stats(const struct cgit_period *period) // whole history and discarding older commits. The check below still // bounds the period edge exactly. rev.max_age = since; - memset(&authors, 0, sizeof(authors)); // A failed setup leaves the walk holding freed commits, so it must // not be read from. if (prepare_revision_walk(&rev)) { cgit_print_error_page(500, "Internal Server Error", "Unable to read the history"); - return authors; + return -1; } while ((commit = get_revision(&rev))) { struct commitinfo *info = cgit_parse_commit(commit); if ((time_t)info->committer_date >= since) - add_commit(&authors, info, period); + add_commit(authors, info, period); cgit_free_commitinfo(info); release_commit_memory(the_repository->parsed_objects, commit); commit->parents = NULL; } - return authors; + return 0; } static int cmp_total_commits(const void *a, const void *b) @@ -431,7 +430,8 @@ const char *cgit_find_stats_periodname(int idx) void cgit_show_stats(void) { - struct string_list authors, labels; + struct string_list authors = STRING_LIST_INIT_NODUP; + struct string_list labels; const struct cgit_period *period; int top, period_index; const char *code = "w"; @@ -448,7 +448,8 @@ void cgit_show_stats(void) cgit_print_error_page(400, "Bad Request", "Statistics type disabled: %s", period->name); return; } - authors = collect_stats(period); + if (collect_stats(period, &authors)) + return; qsort(authors.items, authors.nr, sizeof(struct string_list_item), cmp_total_commits); top = ctx.qry.ofs; |
