commit e4caa658300a7add4b5ea31badafdbec0dc733f7 from: Omar Polo date: Sat Sep 07 08:50:13 2024 UTC gotwebd: centralize the skip tag logic No need to do it twice, just make sure the tailq has the correct entries where it's generated, so in the render code we don't have to duplicate the logic. ok stsp@ commit - 64d30f49d7bb122247fc1ab03df40670ff210369 commit + e4caa658300a7add4b5ea31badafdbec0dc733f7 blob - 542f0c0f02f83e44d87ede48a28af59748768530 blob + f4a93f9f22c2a2ae93a2bf822794bade8af45b6c --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -509,10 +509,6 @@ got_get_repo_tags(struct request *c, size_t limit) if (limit == 1) chk_multi = 0; - - /* - * XXX: again, see previous message about caching - */ TAILQ_FOREACH(re, &refs, entry) { struct repo_tag *new_repo_tag = NULL; @@ -579,13 +575,13 @@ got_get_repo_tags(struct request *c, size_t limit) goto done; if (commit_found == 0 && qs->commit != NULL && - strncmp(id_str, qs->commit, strlen(id_str)) != 0) + strncmp(id_str, qs->commit, strlen(id_str)) != 0) { + TAILQ_REMOVE(&t->repo_tags, new_repo_tag, entry); + gotweb_free_repo_tag(new_repo_tag); continue; - else + } else commit_found = 1; - t->tag_count++; - /* * check for one more commit before breaking, * so we know whether to navigate through briefs blob - ff01852b75f3531996e1e87a3c719dbe369b65d9 blob + fb2894f0a49e2ecb0e12069bb4354470e9c06e32 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -381,7 +381,7 @@ gotweb_process_request(struct request *c) log_warnx("%s: %s", __func__, error->msg); goto err; } - if (c->t->tag_count == 0) { + if (TAILQ_EMPTY(&c->t->repo_tags)) { error = got_error_msg(GOT_ERR_BAD_OBJ_ID, "bad commit id"); goto err; blob - c0047da16df32ddb81665645f2025c12d9cf8250 blob + 59fef09083a448dfb1173969b2c5b5426af439a8 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -202,7 +202,6 @@ struct transport { unsigned int repos_total; unsigned int next_disp; unsigned int prev_disp; - unsigned int tag_count; const struct got_error *error; struct got_blob_object *blob; int fd; blob - 6638943209aae86d6f98b5db64e75ad966980813 blob + 9bc9e41186b83a537530e7cfb4e386bdc1bcfb4d --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -815,26 +815,19 @@ nextsep(char *s, char **t) {! struct request *c = tp->tp_arg; struct transport *t = c->t; - struct querystring *qs = t->qs; struct repo_tag *rt; - int commit_found; - - commit_found = qs->commit == NULL; !}

Tags

- {{ if t->tag_count == 0 }} + {{ if TAILQ_EMPTY(&t->repo_tags) }}
This repository contains no tags
{{ else }} {{ tailq-foreach rt &t->repo_tags entry }} - {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }} - {! commit_found = 1; !} - {{ render tag_item(tp, rt) }} - {{ end }} + {{ render tag_item(tp, rt) }} {{ end }} {{ render gotweb_render_more(tp, TAGS) }} {{ end }}