commit b38bef130a0b3f87cc472394f280940bd4e72238 from: Omar Polo via: Thomas Adam date: Sat Aug 12 11:13:46 2023 UTC gotwebd: fix branches modification time with show_repo_age off If show_repo_age is set to off, got_get_repo_age() returns without setting the timestamp. got_get_repo_age() is also used by the branch listing to show how old they are however, and we end up rendering the stack garbage. Instead, respect `show_repo_age off' one layer above, and always return a timestamp in got_get_repo_age(). While here, initialize the timestamp to zero so it's set also in case of failures. Issue reported on IRC by xs, thanks! commit - 49dff0bd5f1fb112f762312d655dc99d24358c7c commit + b38bef130a0b3f87cc472394f280940bd4e72238 blob - d9bca1235cd0b28e27421abbdb85d29d125bd3f1 blob + 39e6d570aff5f809ccc1326d4431dca03779b3bd --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -128,7 +128,6 @@ const struct got_error * got_get_repo_age(time_t *repo_age, struct request *c, const char *refname) { const struct got_error *error = NULL; - struct server *srv = c->srv; struct transport *t = c->t; struct got_repository *repo = t->repo; struct got_commit_object *commit = NULL; @@ -138,8 +137,7 @@ got_get_repo_age(time_t *repo_age, struct request *c, TAILQ_INIT(&refs); - if (srv->show_repo_age == 0) - return NULL; + *repo_age = 0; error = got_ref_list(&refs, repo, "refs/heads", got_ref_cmp_by_name, NULL); blob - 79df2ff2984a3bd08bb77442ab360973d9c35cf7 blob + 96f09e96a245ef57f71cf92d5933096ef5eb9f32 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -1218,11 +1218,13 @@ done: if (error) goto err; error = got_get_repo_owner(&repo_dir->owner, c); - if (error) - goto err; - error = got_get_repo_age(&repo_dir->age, c, NULL); if (error) goto err; + if (srv->show_repo_age) { + error = got_get_repo_age(&repo_dir->age, c, NULL); + if (error) + goto err; + } error = gotweb_get_clone_url(&repo_dir->url, srv, repo_dir->path, dirfd(dt)); err: