Warmcat homepage andy@warmcat.com
libwebsockets
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1745907135, "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":"b6a1d3c4e66b3713723ddf0de51aa828", "commit": {"type":"commit", "time": 1530115980, "time_ofs": 120, "oid_tree": { "oid": "8fc7db6324b6483939cdfcf201793866877a5d92", "alias": []}, "oid":{ "oid": "2f8648ff7f5c7119ab035c134504f04eefe068fb", "alias": []}, "msg": "snapshot: strip bit from struct cgit_snapshot_format", "sig_commit": { "git_time": { "time": 1530115980, "offset": 120 }, "name": "Jason A. Donenfeld", "email": "Jason@zx2c4.com", "md5": "689e78dac56e3d77d7f74984912487d3" }, "sig_author": { "git_time": { "time": 1528698419, "offset": 120 }, "name": "Christian Hesse", "email": "mail@eworm.de", "md5": "d39edb2018ca5544c1c390a8266096fb" }}, "body": "snapshot: strip bit from struct cgit_snapshot_format\n\nWe had a static bit value in struct cgit_snapshot_format. We do not rely\non it and things can be calculated on the fly. So strip it.\n\nSigned-off-by: Christian Hesse \u003cmail@eworm.de\u003e\n" , "diff": "diff --git a/cgit.c b/cgit.c\nindex d2f7b9c..ca0a89c 100644\n--- a/cgit.c\n+++ b/cgit.c\n@@ -765,7 +765,7 @@ static char *build_snapshot_setting(int bitmap)\n \tstruct strbuf result \u003d STRBUF_INIT;\n \n \tfor (f \u003d cgit_snapshot_formats; f-\u003esuffix; f++) {\n-\t\tif (f-\u003ebit \u0026 bitmap) {\n+\t\tif (cgit_snapshot_format_bit(f) \u0026 bitmap) {\n \t\t\tif (result.len)\n \t\t\t\tstrbuf_addch(\u0026result, ' ');\n \t\t\tstrbuf_addstr(\u0026result, f-\u003esuffix);\ndiff --git a/cgit.h b/cgit.h\nindex a686390..0798dc5 100644\n--- a/cgit.h\n+++ b/cgit.h\n@@ -46,6 +46,8 @@\n */\n #define PAGE_ENCODING \u0022UTF-8\u0022\n \n+#define BIT(x)\t(1U \u003c\u003c (x))\n+\n typedef void (*configfn)(const char *name, const char *value);\n typedef void (*filepair_fn)(struct diff_filepair *pair);\n typedef void (*linediff_fn)(char *line, int len);\n@@ -314,7 +316,6 @@ struct cgit_snapshot_format {\n \tconst char *suffix;\n \tconst char *mimetype;\n \twrite_archive_fn_t write_func;\n-\tint bit;\n };\n \n extern const char *cgit_version;\n@@ -376,6 +377,7 @@ extern const char *cgit_repobasename(const char *reponame);\n extern int cgit_parse_snapshots_mask(const char *str);\n extern const struct object_id *cgit_snapshot_get_sig(const char *ref,\n \t\t\t\t\t\t const struct cgit_snapshot_format *f);\n+extern const unsigned cgit_snapshot_format_bit(const struct cgit_snapshot_format *f);\n \n extern int cgit_open_filter(struct cgit_filter *filter, ...);\n extern int cgit_close_filter(struct cgit_filter *filter);\ndiff --git a/shared.c b/shared.c\nindex 0a11e68..d59ae7e 100644\n--- a/shared.c\n+++ b/shared.c\n@@ -400,7 +400,7 @@ int cgit_parse_snapshots_mask(const char *str)\n \t\tfor (f \u003d cgit_snapshot_formats; f-\u003esuffix; f++) {\n \t\t\tif (!strcmp(item-\u003estring, f-\u003esuffix) ||\n \t\t\t !strcmp(item-\u003estring, f-\u003esuffix + 1)) {\n-\t\t\t\trv |\u003d f-\u003ebit;\n+\t\t\t\trv |\u003d cgit_snapshot_format_bit(f);\n \t\t\t\tbreak;\n \t\t\t}\n \t\t}\ndiff --git a/ui-shared.c b/ui-shared.c\nindex 8a786e0..e8c0723 100644\n--- a/ui-shared.c\n+++ b/ui-shared.c\n@@ -1127,7 +1127,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,\n \n \tprefixlen \u003d filename.len;\n \tfor (f \u003d cgit_snapshot_formats; f-\u003esuffix; f++) {\n-\t\tif (!(repo-\u003esnapshots \u0026 f-\u003ebit))\n+\t\tif (!(repo-\u003esnapshots \u0026 cgit_snapshot_format_bit(f)))\n \t\t\tcontinue;\n \t\tstrbuf_setlen(\u0026filename, prefixlen);\n \t\tstrbuf_addstr(\u0026filename, f-\u003esuffix);\ndiff --git a/ui-snapshot.c b/ui-snapshot.c\nindex c7611e8..83ce6e8 100644\n--- a/ui-snapshot.c\n+++ b/ui-snapshot.c\n@@ -86,11 +86,11 @@ static int write_tar_xz_archive(const char *hex, const char *prefix)\n }\n \n const struct cgit_snapshot_format cgit_snapshot_formats[] \u003d {\n-\t{ \u0022.zip\u0022, \u0022application/x-zip\u0022, write_zip_archive, 0x01 },\n-\t{ \u0022.tar.gz\u0022, \u0022application/x-gzip\u0022, write_tar_gzip_archive, 0x02 },\n-\t{ \u0022.tar.bz2\u0022, \u0022application/x-bzip2\u0022, write_tar_bzip2_archive, 0x04 },\n-\t{ \u0022.tar\u0022, \u0022application/x-tar\u0022, write_tar_archive, 0x08 },\n-\t{ \u0022.tar.xz\u0022, \u0022application/x-xz\u0022, write_tar_xz_archive, 0x10 },\n+\t{ \u0022.tar\u0022,\t\u0022application/x-tar\u0022,\twrite_tar_archive\t},\n+\t{ \u0022.tar.gz\u0022,\t\u0022application/x-gzip\u0022,\twrite_tar_gzip_archive\t},\n+\t{ \u0022.tar.bz2\u0022,\t\u0022application/x-bzip2\u0022,\twrite_tar_bzip2_archive\t},\n+\t{ \u0022.tar.xz\u0022,\t\u0022application/x-xz\u0022,\twrite_tar_xz_archive\t},\n+\t{ \u0022.zip\u0022,\t\u0022application/x-zip\u0022,\twrite_zip_archive\t},\n \t{ NULL }\n };\n \n@@ -130,6 +130,11 @@ static const struct cgit_snapshot_format *get_format(const char *filename)\n \treturn NULL;\n }\n \n+const unsigned cgit_snapshot_format_bit(const struct cgit_snapshot_format *f)\n+{\n+\treturn BIT(f - \u0026cgit_snapshot_formats[0]);\n+}\n+\n static int make_snapshot(const struct cgit_snapshot_format *format,\n \t\t\t const char *hex, const char *prefix,\n \t\t\t const char *filename)\n@@ -263,7 +268,7 @@ void cgit_print_snapshot(const char *head, const char *hex,\n \t}\n \n \tf \u003d get_format(filename);\n-\tif (!f || !(ctx.repo-\u003esnapshots \u0026 f-\u003ebit)) {\n+\tif (!f || !(ctx.repo-\u003esnapshots \u0026 cgit_snapshot_format_bit(f))) {\n \t\tcgit_print_error_page(400, \u0022Bad request\u0022,\n \t\t\t\t\u0022Unsupported snapshot format: %s\u0022, filename);\n \t\treturn;\n","s":{"c":1745907135,"u": 5678}} ],"g": 6503,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}