commit 59ec6f30d83e4bdac0699743000c51dc4a55230de4ac589d4d6ff2dc3d432315 from: Stefan Sperling date: Wed Feb 4 21:01:20 2026 UTC add a per-repository clone_url option gotwebd.conf This feature can be used to set a clone URL without having to create a file inside the repository. commit - f7321f76f782d54a93e0e4c48db2cf7c83bbfd92405a544d12aa110eb48caf83 commit + 59ec6f30d83e4bdac0699743000c51dc4a55230de4ac589d4d6ff2dc3d432315 blob - d11e5cc622139290c79cc1cb2cc59a39cfebf0733c8a157429e1402bb7fc636e blob + afb941d11c2f4b76ca11d027bd0e6017a1fadbbf73be6829ab48f7c3eddba93d --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -1698,8 +1698,16 @@ gotweb_load_got_path(struct repo_dir **rp, const char if (error) goto err; } - error = gotweb_get_clone_url(&repo_dir->url, srv, repo_dir->path, - dirfd(dt)); + if (srv->show_repo_cloneurl && repo && repo->clone_url[0] != '\0') { + repo_dir->url = strdup(repo->clone_url); + if (repo_dir->url == NULL) { + error = got_error_from_errno("strdup"); + goto err; + } + } else { + error = gotweb_get_clone_url(&repo_dir->url, srv, + repo_dir->path, dirfd(dt)); + } err: free(dir_test); if (dt != NULL && closedir(dt) == EOF && error == NULL) blob - bd2ce4ee4a4ccaa51279e63e8d7821741ab9aa250d570e6e4b462766154158b7 blob + 7bfc78da3b956a3db5dfeea9fc8f830e8d205d836e6d41dcaa34c072942d56d0 --- gotwebd/gotwebd.conf.5 +++ gotwebd/gotwebd.conf.5 @@ -481,6 +481,22 @@ is enabled. .Pp The available repository configuration directives are as follows: .Bl -tag -width Ds +.It Ic clone_url Ar string +Sets the repository Git clone URL shown on the repository summary page. +The +.Ar string +parameter should be wrapped in quotes and should be a valid URL for use +with +.Ic got clone +or +.Ic git clone . +.Pp +If no clone URL is set in +.Nm +then URLs stored in the repository's +.Pa cloneurl +file will be shown instead. +This file may contain multiple URLs, one per line. .It Ic description Ar string Sets the repository description shown on the repository listing page. The @@ -640,7 +656,9 @@ Toggle display of last repository modification date. Enabled by default. .It Ic show_repo_cloneurl Ar on | off Toggle display of clone URLs for a repository. -This requires the creation of a +This requires the repository's +.iC clone_url +option to be set, or requires the creation of a .Pa cloneurl file inside the repository which contains one URL per line. Enabled by default. blob - 383b6060b9e28e0935f8066081fa7403c2349aff4fa342b4ae4d6d3f7f370dc7 blob + 2fafef4bd410c374c62aa416c81e871b4f13e74eec560433e690e13a13510fa5 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -397,6 +397,7 @@ struct gotwebd_repo { char name[NAME_MAX]; char description[GOTWEBD_MAXDESCRSZ]; + char clone_url[GOTWEBD_MAXCLONEURLSZ]; enum gotwebd_auth_config auth_config; struct gotwebd_access_rule_list access_rules; blob - a18b601e76dc2fa0b895bd887b2b11448196cfb25b599573bc9fcdf12bf00f26 blob + 4c1860a2ed56a660388fd7001629ed5662e7baa2027e97108e3faf9331502481 --- gotwebd/parse.y +++ gotwebd/parse.y @@ -149,7 +149,7 @@ mediatype_ok(const char *s) %} %token LISTEN GOTWEBD_LOGIN WWW SITE_NAME SITE_OWNER SITE_LINK LOGO -%token LOGO_URL SHOW_REPO_OWNER SHOW_REPO_AGE SHOW_REPO_DESCRIPTION +%token LOGO_URL SHOW_REPO_OWNER SHOW_REPO_AGE SHOW_REPO_DESCRIPTION CLONE_URL %token MAX_REPOS_DISPLAY REPOS_PATH MAX_COMMITS_DISPLAY ON ERROR %token SHOW_SITE_OWNER SHOW_REPO_CLONEURL PORT PREFORK RESPECT_EXPORTOK %token SERVER CHROOT CUSTOM_CSS SOCKET HINT HTDOCS GOTWEB_URL_ROOT @@ -967,6 +967,17 @@ repoopts1 : DISABLE AUTHENTICATION { YYERROR; } } + | CLONE_URL STRING { + n = strlcpy(new_repo->clone_url, $2, + sizeof(new_repo->clone_url)); + if (n >= sizeof(new_repo->clone_url)) { + yyerror("repository clone URL too long, " + "exceeds %zd bytes", + sizeof(new_repo->clone_url) - 1); + free($2); + YYERROR; + } + } ; types : TYPES '{' optnl mediaopts_l '}' @@ -1079,6 +1090,7 @@ lookup(char *s) { "authentication", AUTHENTICATION }, { "branch", BRANCH }, { "chroot", CHROOT }, + { "clone_url", CLONE_URL }, { "control", GOTWEBD_CONTROL }, { "custom_css", CUSTOM_CSS }, { "deny", DENY },