commit b3ba36c380dd6686b46f27d33ed4e8ee67d7426d from: Omar Polo via: Thomas Adam date: Sat Jan 14 16:45:29 2023 UTC gotwebd: bubble up got_get_repo_tags This bubbles up the call to got_get_repo_tags from gotweb_render_tags to its caller, gotweb_process_request and gotweb_render_summary. It helps simplifying gotweb_render_summary and making it easier to templateify, but also helps in untangling a bit the code. At this point gotweb_render_tags becomes just a wrapper to gotweb_render_tags_tmpl so switch completely to it. ok jamsek commit - 00abe30b6011e389018622a47995f9390b166182 commit + b3ba36c380dd6686b46f27d33ed4e8ee67d7426d blob - ecb30578057b82335c755ebafb9d9c1fdd24cf97 blob + b0990fa5496b65df45995ab15153323795171ee9 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -96,7 +96,6 @@ static const struct got_error *gotweb_get_clone_url(ch const char *, int); static const struct got_error *gotweb_render_blame(struct request *); static const struct got_error *gotweb_render_summary(struct request *); -static const struct got_error *gotweb_render_tags(struct request *); static void gotweb_free_querystring(struct querystring *); static void gotweb_free_repo_dir(struct repo_dir *); @@ -311,11 +310,13 @@ render: goto done; break; case TAGS: - error = gotweb_render_tags(c); + error = got_get_repo_tags(c, srv->max_commits_display); if (error) { log_warnx("%s: %s", __func__, error->msg); goto err; } + if (gotweb_render_tags(c->tp) == -1) + goto done; break; case TREE: error = got_get_repo_commits(c, 1); @@ -1017,6 +1018,7 @@ gotweb_render_summary(struct request *c) const struct got_error *error = NULL; struct got_reflist_head refs; struct transport *t = c->t; + struct querystring *qs = t->qs; struct got_repository *repo = t->repo; struct server *srv = c->srv; int r; @@ -1072,40 +1074,19 @@ gotweb_render_summary(struct request *c) goto done; if (gotweb_render_briefs(c->tp) == -1) - goto done; - - error = gotweb_render_tags(c); - if (error) { - log_warnx("%s: %s", __func__, error->msg); goto done; - } - gotweb_render_branches(c->tp, &refs); -done: - got_ref_list_free(&refs); - return error; -} - -static const struct got_error * -gotweb_render_tags(struct request *c) -{ - const struct got_error *error = NULL; - struct server *srv = c->srv; - struct transport *t = c->t; - struct querystring *qs = t->qs; - - if (qs->action == BRIEFS) { - qs->action = TAGS; - error = got_get_repo_tags(c, D_MAXSLCOMMDISP); - } else - error = got_get_repo_tags(c, srv->max_commits_display); + qs->action = TAGS; + error = got_get_repo_tags(c, D_MAXSLCOMMDISP); if (error) goto done; - if (gotweb_render_tags_tmpl(c->tp) == -1) + if (gotweb_render_tags(c->tp) == -1) goto done; + gotweb_render_branches(c->tp, &refs); done: + got_ref_list_free(&refs); return error; } blob - 01a426c9ded760150f5157900a24d3874a0f178d blob + c625c27f2bee1409fe6562219936a8d0e9948a55 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -472,7 +472,7 @@ int gotweb_render_navs(struct template *); int gotweb_render_commits(struct template *); int gotweb_render_blob(struct template *, struct got_blob_object *); int gotweb_render_tree(struct template *); -int gotweb_render_tags_tmpl(struct template *); +int gotweb_render_tags(struct template *); int gotweb_render_tag(struct template *); int gotweb_render_diff(struct template *, FILE *); int gotweb_render_branches(struct template *, struct got_reflist_head *); blob - 1ee4d93d857e50deb09f255fd23369630dd7c910 blob + 086325e9d628e2ff56488783ccdc6d871efc5089 --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -576,7 +576,7 @@ gotweb_render_age(struct template *tp, time_t time, in !} {{ end }} -{{ define gotweb_render_tags_tmpl(struct template *tp) }} +{{ define gotweb_render_tags(struct template *tp) }} {! struct request *c = tp->tp_arg; struct transport *t = c->t;