From: Stefan Sperling Subject: Re: gotwebd: fix links to the README in the summary view To: Omar Polo Cc: gameoftrees@openbsd.org Date: Fri, 2 Aug 2024 12:48:44 +0200 On Fri, Aug 02, 2024 at 11:34:44AM +0200, Omar Polo wrote: > currently the link to the "README" in the tree view in the summary page > is broken because it lacks the "folder" and "commit" query parameters. > This because the summary page doesn't have these query arg, so when we > try to use them in tree_listing() (in pages.tmpl) they're unset and a > bad link is generated. > > instead, fill qs->commit in the SUMMARY case, using the first commit to > avoid having to resolve refs again. > > ok? nice, ok > > diff /home/op/w/got > commit - ae00edffd4756449c159d45b52fe67f4adf1c694 > path + /home/op/w/got > blob - e8446a2194429a9db4ce01e2e0b35bb60a4745f4 > file + gotwebd/gotweb.c > --- gotwebd/gotweb.c > +++ gotwebd/gotweb.c > @@ -147,6 +147,7 @@ gotweb_process_request(struct request *c) > struct server *srv = NULL; > struct querystring *qs = NULL; > struct repo_dir *repo_dir = NULL; > + struct repo_commit *commit; > const char *rss_ctype = "application/rss+xml;charset=utf-8"; > const uint8_t *buf; > size_t len; > @@ -353,6 +354,15 @@ gotweb_process_request(struct request *c) > error = got_get_repo_commits(c, srv->summary_commits_display); > if (error) > goto err; > + commit = TAILQ_FIRST(&c->t->repo_commits); > + if (commit && qs->commit == NULL) { > + qs->commit = strdup(commit->commit_id); > + if (qs->commit == NULL) { > + error = got_error_from_errno("strdup"); > + log_warn("%s: strdup", __func__); > + goto err; > + } > + } > qs->action = TAGS; > error = got_get_repo_tags(c, srv->summary_tags_display); > if (error) { > blob - 22583fa65fa1ec7208c4cc6061197077ced00de8 > file + gotwebd/pages.tmpl > --- gotwebd/pages.tmpl > +++ gotwebd/pages.tmpl > @@ -672,7 +672,7 @@ nextsep(char *s, char **t) > url.action = BLOB; > url.path = t->qs->path; > url.file = readme; > - url.folder = t->qs->folder; > + url.folder = t->qs->folder ? t->qs->folder : ""; > url.commit = t->qs->commit; > !} > {{ if !binary }} > >