"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
gotwebd: branches modification vs show_repo_age off
To:
gameoftrees@openbsd.org
Date:
Mon, 07 Aug 2023 18:01:10 +0200

Download raw body.

Thread
it was reported by xs on IRC.  If show_repo_age is off we never set
the timestamp got_get_repo_age() and when this function is called by
branch() in pages.tmpl we print the garbage on the stack as timestamp.
In xs case it happened to be a number equal to or greater than the
current timestamp and so print "right now" always.

So, drop the check in got_get_repo_age() and always initialize the
repo_age to zero, and respect show_repo_age in an upper layer.

ok?

diff /home/op/w/got
commit - 07d8d6083dc8bd84b2c7ca96068ce3c35f8c1dbf
path + /home/op/w/got
blob - a7525287e2c962f40938fd909cdb0b9142d1f605
file + gotwebd/got_operations.c
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
@@ -128,7 +128,6 @@ got_get_repo_age(time_t *repo_age, struct request *c, 
 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 - f481972feb3305dfe470ae86b2a645949baf4045
file + gotwebd/gotweb.c
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -1221,9 +1221,11 @@ done:
 	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: