commit d60961d296583c78051ab30aeee8171fd9611aac from: Omar Polo date: Fri Jan 13 07:52:02 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 - 3ab2c91424750aef75f929402e6a7581a704f36d commit + d60961d296583c78051ab30aeee8171fd9611aac blob - df7d335b7261e2e7472a0004b490f669e3a56351 blob + 9eae54b709c09442a47bd69906eaaeb07cedf24a --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -95,7 +95,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 *); @@ -310,11 +309,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); @@ -1016,6 +1017,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; @@ -1071,40 +1073,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 - 47eed11a0ded054e1f08fe6bee4bc4b5af4aea0e blob + 23e9968ddbd0cb2c3610a66a962d4d36e4732208 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -470,7 +470,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 - 6cf6d4d7e32e66e8dbd1cf8b8d9740fec9fe9ef2 blob + f915e92c66d33c3821c4e30fb4e0860aaa53d2bc --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -577,7 +577,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;