From 8c4f99487c5b7de3fc5094d74f91cfb8ceea2cc1 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:21:53 -0700 Subject: Build the patch and stats arguments in a strvec --- source/ui-stats.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'source/ui-stats.c') diff --git a/source/ui-stats.c b/source/ui-stats.c index 4ed956c..9c79e74 100644 --- a/source/ui-stats.c +++ b/source/ui-stats.c @@ -215,26 +215,19 @@ static int collect_stats(const struct cgit_period *period, struct string_list *a { struct rev_info rev; struct commit *commit; - // setup_revisions reads these the way main does, skipping the first - // entry, and reads past the count up to a NULL after the double dash, - // so the sentinel has to stay even when the path fills the slot before - // it. - const char *argv[] = { NULL, ctx.qry.head, NULL, NULL, NULL }; - int argc = 2; + struct strvec argv = STRVEC_INIT; time_t since; struct tm tm; window_start(period, &tm); since = timegm(&tm); - if (ctx.qry.path) { - argv[2] = "--"; - argv[3] = ctx.qry.path; - argc += 2; - } + strvec_pushl(&argv, "stats", ctx.qry.head, NULL); + if (ctx.qry.path) + strvec_pushl(&argv, "--", ctx.qry.path, NULL); repo_init_revisions(the_repository, &rev, NULL); rev.max_parents = 1; - setup_revisions(argc, argv, &rev, NULL); + setup_revisions(argv.nr, argv.v, &rev, NULL); // Prune the walk to the displayed window instead of traversing the // whole history and discarding older commits. The check below still // bounds the period edge exactly. @@ -243,6 +236,7 @@ static int collect_stats(const struct cgit_period *period, struct string_list *a // not be read from. if (prepare_revision_walk(&rev)) { cgit_print_error_page(500, "Internal Server Error", "Unable to read the history"); + strvec_clear(&argv); return -1; } while ((commit = get_revision(&rev))) { @@ -255,6 +249,7 @@ static int collect_stats(const struct cgit_period *period, struct string_list *a release_commit_memory(the_repository->parsed_objects, commit); commit->parents = NULL; } + strvec_clear(&argv); return 0; } -- cgit