Warmcat homepage andy@warmcat.com
libwebsockets
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1745906513, "reponame":"cgit", "desc":"CGI gitweb", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://warmcat.com/repo/cgit", "f":3, "items": [ {"schema":"libjg2-1", "cid":"c7ad9d39eb287117be7e28c56f2397aa", "commit": {"type":"commit", "time": 1530115879, "time_ofs": 120, "oid_tree": { "oid": "5f31bf0e4ca63ab94b74a85897d37481474c92a0", "alias": []}, "oid":{ "oid": "c1572bb5ec4540b5008490cf471cc4a5e65ef728", "alias": []}, "msg": "Add \u0022snapshot-prefix\u0022 repo configuration", "sig_commit": { "git_time": { "time": 1530115879, "offset": 120 }, "name": "Jason A. Donenfeld", "email": "Jason@zx2c4.com", "md5": "689e78dac56e3d77d7f74984912487d3" }, "sig_author": { "git_time": { "time": 1522502401, "offset": 60 }, "name": "John Keeping", "email": "john@keeping.me.uk", "md5": "aea7d8738c91da1cb0dfa9d86f2bbc47" }}, "body": "Add \u0022snapshot-prefix\u0022 repo configuration\n\nAllow using a user-specified value for the prefix in snapshot files\ninstead of the repository basename. For example, files downloaded from\nthe linux-stable.git repository should be named linux-$VERSION and not\nlinux-stable-$VERSION, which can be achieved by setting:\n\n\trepo.snapshot-prefix\u003dlinux\n\nSigned-off-by: John Keeping \u003cjohn@keeping.me.uk\u003e\nReviewed-by: Christian Hesse \u003cmail@eworm.de\u003e\n" , "diff": "diff --git a/cgit.c b/cgit.c\nindex bd9cb3f..d2f7b9c 100644\n--- a/cgit.c\n+++ b/cgit.c\n@@ -79,6 +79,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va\n \t\titem-\u003eutil \u003d xstrdup(value);\n \t} else if (!strcmp(name, \u0022section\u0022))\n \t\trepo-\u003esection \u003d xstrdup(value);\n+\telse if (!strcmp(name, \u0022snapshot-prefix\u0022))\n+\t\trepo-\u003esnapshot_prefix \u003d xstrdup(value);\n \telse if (!strcmp(name, \u0022readme\u0022) \u0026\u0026 value !\u003d NULL) {\n \t\tif (repo-\u003ereadme.items \u003d\u003d ctx.cfg.readme.items)\n \t\t\tmemset(\u0026repo-\u003ereadme, 0, sizeof(repo-\u003ereadme));\ndiff --git a/cgit.h b/cgit.h\nindex 005ae63..847cd2e 100644\n--- a/cgit.h\n+++ b/cgit.h\n@@ -88,6 +88,7 @@ struct cgit_repo {\n \tchar *clone_url;\n \tchar *logo;\n \tchar *logo_link;\n+\tchar *snapshot_prefix;\n \tint snapshots;\n \tint enable_commit_graph;\n \tint enable_log_filecount;\ndiff --git a/cgitrc.5.txt b/cgitrc.5.txt\nindex 4da166c..a9d3d0a 100644\n--- a/cgitrc.5.txt\n+++ b/cgitrc.5.txt\n@@ -599,6 +599,13 @@ repo.snapshots::\n \trestricted by the global \u0022snapshots\u0022 setting. Default value:\n \t\u003csnapshots\u003e.\n \n+repo.snapshot-prefix::\n+\tPrefix to use for snapshot links instead of the repository basename.\n+\tFor example, the \u0022linux-stable\u0022 repository may wish to set this to\n+\t\u0022linux\u0022 so that snapshots are in the format \u0022linux-3.15.4\u0022 instead\n+\tof \u0022linux-stable-3.15.4\u0022. Default value: \u003cempty\u003e meaning to use\n+\tthe repository basename.\n+\n repo.section::\n \tOverride the current section name for this repository. Default value:\n \tnone.\ndiff --git a/ui-refs.c b/ui-refs.c\nindex 75f2789..50d9d30 100644\n--- a/ui-refs.c\n+++ b/ui-refs.c\n@@ -100,7 +100,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref)\n \tif (!ref || strlen(ref) \u003c 1)\n \t\treturn;\n \n-\tbasename \u003d cgit_repobasename(repo-\u003eurl);\n+\tbasename \u003d cgit_snapshot_prefix(repo);\n \tif (starts_with(ref, basename))\n \t\tstrbuf_addstr(\u0026filename, ref);\n \telse\ndiff --git a/ui-shared.c b/ui-shared.c\nindex e719c1b..d857873 100644\n--- a/ui-shared.c\n+++ b/ui-shared.c\n@@ -152,6 +152,14 @@ const char *cgit_repobasename(const char *reponame)\n \treturn rvbuf;\n }\n \n+const char *cgit_snapshot_prefix(const struct cgit_repo *repo)\n+{\n+\tif (repo-\u003esnapshot_prefix)\n+\t\treturn repo-\u003esnapshot_prefix;\n+\n+\treturn cgit_repobasename(repo-\u003eurl);\n+}\n+\n static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root)\n {\n \tchar *delim \u003d \u0022?\u0022;\n@@ -1110,7 +1118,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *head,\n \tstruct strbuf filename \u003d STRBUF_INIT;\n \tsize_t prefixlen;\n \n-\tcgit_compose_snapshot_prefix(\u0026filename, cgit_repobasename(repo-\u003eurl), hex);\n+\tcgit_compose_snapshot_prefix(\u0026filename, cgit_snapshot_prefix(repo), hex);\n \tprefixlen \u003d filename.len;\n \tfor (f \u003d cgit_snapshot_formats; f-\u003esuffix; f++) {\n \t\tif (!(repo-\u003esnapshots \u0026 f-\u003ebit))\ndiff --git a/ui-shared.h b/ui-shared.h\nindex b3eb8c5..92a1755 100644\n--- a/ui-shared.h\n+++ b/ui-shared.h\n@@ -78,6 +78,7 @@ extern void cgit_compose_snapshot_prefix(struct strbuf *filename,\n \t\t\t\t\t const char *base, const char *ref);\n extern void cgit_print_snapshot_links(const struct cgit_repo *repo,\n \t\t\t\t const char *head, const char *hex);\n+extern const char *cgit_snapshot_prefix(const struct cgit_repo *repo);\n extern void cgit_add_hidden_formfields(int incl_head, int incl_search,\n \t\t\t\t const char *page);\n \ndiff --git a/ui-snapshot.c b/ui-snapshot.c\nindex 237a75f..b9e2a36 100644\n--- a/ui-snapshot.c\n+++ b/ui-snapshot.c\n@@ -154,7 +154,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo,\n \tif (get_oid(snapshot.buf, \u0026oid) \u003d\u003d 0)\n \t\tgoto out;\n \n-\treponame \u003d cgit_repobasename(repo-\u003eurl);\n+\treponame \u003d cgit_snapshot_prefix(repo);\n \tif (starts_with(snapshot.buf, reponame)) {\n \t\tconst char *new_start \u003d snapshot.buf;\n \t\tnew_start +\u003d strlen(reponame);\n@@ -214,7 +214,7 @@ void cgit_print_snapshot(const char *head, const char *hex,\n \t\thex \u003d head;\n \n \tif (!prefix)\n-\t\tprefix \u003d xstrdup(cgit_repobasename(ctx.repo-\u003eurl));\n+\t\tprefix \u003d xstrdup(cgit_snapshot_prefix(ctx.repo));\n \n \tmake_snapshot(f, hex, prefix, filename);\n \tfree(prefix);\n","s":{"c":1745624963,"u": 5037}} ],"g": 1849,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "7d0a"}