[PATCH] Update .mailmap with my new email address
Signed-off-by: Lukas Fleischer --- .mailmap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index ca6b57e..03b5479 100644 --- a/.mailmap +++ b/.mailmap @@ -5,6 +5,6 @@ Lars Hjemli Lars Hjemli Lars Hjemli Lars Hjemli -Lukas Fleischer -Lukas Fleischer +Lukas Fleischer +Lukas Fleischer Stefan Bühler -- 2.13.3 ___ CGit mailing list CGit@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 1/1] ui-repolist: remove unused variable
On Tue, 06 Jun 2017 at 16:14:47, Christian Hesse wrote: > From: Christian Hesse > > Signed-off-by: Christian Hesse > --- > ui-repolist.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/ui-repolist.c b/ui-repolist.c > index 20a4f56..7272e87 100644 > --- a/ui-repolist.c > +++ b/ui-repolist.c > @@ -225,7 +225,6 @@ static int sort_section(const void *a, const void *b) > const struct cgit_repo *r1 = a; > const struct cgit_repo *r2 = b; > int result; > - time_t t; > [...] Looks good to me. I already posted pretty much the same patch (and queued it on lf/for-jason) back in April, though [1]. Jason, any chance you can go through our for-jason branches and merge them anytime soon? Regards, Lukas [1] https://lists.zx2c4.com/pipermail/cgit/2017-April/003532.html ___ CGit mailing list CGit@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Remove unused variable from sort_section()
On Wed, 05 Apr 2017 at 12:28:28, Jason A. Donenfeld wrote: > Looks good to me. Queued on lf/for-jason. ___ CGit mailing list CGit@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Remove unused variable from sort_section()
Signed-off-by: Lukas Fleischer --- ui-repolist.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ui-repolist.c b/ui-repolist.c index 20a4f56..7272e87 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -225,7 +225,6 @@ static int sort_section(const void *a, const void *b) const struct cgit_repo *r1 = a; const struct cgit_repo *r2 = b; int result; - time_t t; result = cmp(r1->section, r2->section); if (!result) { -- 2.12.2 ___ CGit mailing list CGit@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] ui-patch: fix segfault when a path prefix is passed
On Sun, 22 Jan 2017 at 23:45:01, Jason A. Donenfeld wrote: > Nice catch, thanks. > > Merged. Note that I had a similar patch submitted to the mailing list about two months ago [1] and queued up in lf/for-jason as you told me back then. Could you check whether the additional changes I have in my version of the patch are worth applying on top of what we now have in master? Regards, Lukas [1] https://lists.zx2c4.com/pipermail/cgit/2016-November/003431.html ___ CGit mailing list CGit@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Fix crash when using path limit
The array passed to setup_revisions() must be NULL-terminated. Fixes a regression introduced in 455b598 (ui-patch.c: Use log_tree_commit() to generate diffs, 2013-08-20). Reported-by: Florian Pritz Signed-off-by: Lukas Fleischer --- ui-patch.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ui-patch.c b/ui-patch.c index ec7f352..047e2f9 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -18,8 +18,8 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, struct commit *commit; struct object_id new_rev_oid, old_rev_oid; char rev_range[2 * 40 + 3]; - const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix }; - int rev_argc = ARRAY_SIZE(rev_argv); + const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix, NULL }; + int rev_argc = ARRAY_SIZE(rev_argv) - 1; char *patchname; if (!prefix) @@ -85,8 +85,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, DIFF_FORMAT_PATCH | DIFF_FORMAT_SUMMARY; if (prefix) rev.diffopt.stat_sep = fmt("(limited to '%s')\n\n", prefix); - setup_revisions(ARRAY_SIZE(rev_argv), rev_argv, &rev, - NULL); + setup_revisions(rev_argc, rev_argv, &rev, NULL); prepare_revision_walk(&rev); while ((commit = get_revision(&rev)) != NULL) { -- 2.10.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Crash when using path limit in ui-patch.c
On Thu, 24 Nov 2016 at 19:49:06, John Keeping wrote: > [...] > diff --git a/ui-patch.c b/ui-patch.c > index ec7f3523..d29f74c7 100644 > --- a/ui-patch.c > +++ b/ui-patch.c > @@ -85,8 +85,7 @@ void cgit_print_patch(const char *new_rev, const char > *old_rev, > DIFF_FORMAT_PATCH | DIFF_FORMAT_SUMMARY; > if (prefix) > rev.diffopt.stat_sep = fmt("(limited to '%s')\n\n", prefix); > - setup_revisions(ARRAY_SIZE(rev_argv), rev_argv, &rev, > - NULL); > + setup_revisions(rev_argc, rev_argv, &rev, NULL); I noticed that, too, when trying to find the culprit but the actual issue is that the array is not NULL-terminated. Will submit a patch soon. > prepare_revision_walk(&rev); > > while ((commit = get_revision(&rev)) != NULL) { > ___ > CGit mailing list > CGit@lists.zx2c4.com > http://lists.zx2c4.com/mailman/listinfo/cgit ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: RFC: don't cache objects larger than X
On Wed, 12 Oct 2016 at 13:22:34, Jason A. Donenfeld wrote: > I face this same problem, in fact. Unless somebody beats me to it, I'd > be interested in giving this a stab. > > One issue is that cache entries are currently "streamed" into the > cache files, as they're produced. It's not trivially possible to know > how big it's going to be beforehand. This means that the best we could > do would be to just immediately unlink it after creation and printing. > Would this be acceptable? It is not easy to compute the exact size of the generated page but we are able to detect huge objects before streaming -- the size of the object is already returned by read_sha1_file(). I wonder whether the max-blob-size setting already does what you want, though? It does not only affect the cached version but it seems better to prevent from generating such huge pages in the first place. If you really want to offer such files to your users, the max_blob_size check in print_object() might be a good place to add the "print but do not cache large files" functionality. Regards, Lukas ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Use skip_prefix() to get rid of magic constants
Signed-off-by: Lukas Fleischer --- cgit.c | 56 ++-- scan-tree.c | 6 -- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/cgit.c b/cgit.c index 2f29aa6..bc05f1e 100644 --- a/cgit.c +++ b/cgit.c @@ -31,6 +31,7 @@ static void process_cached_repolist(const char *path); static void repo_config(struct cgit_repo *repo, const char *name, const char *value) { + const char *path; struct string_list_item *item; if (!strcmp(name, "name")) @@ -73,8 +74,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->max_stats = cgit_find_stats_period(value, NULL); else if (!strcmp(name, "module-link")) repo->module_link= xstrdup(value); - else if (starts_with(name, "module-link.")) { - item = string_list_append(&repo->submodules, xstrdup(name + 12)); + else if (skip_prefix(name, "module-link.", &path)) { + item = string_list_append(&repo->submodules, xstrdup(path)); item->util = xstrdup(value); } else if (!strcmp(name, "section")) repo->section = xstrdup(value); @@ -106,14 +107,16 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va static void config_cb(const char *name, const char *value) { + const char *arg; + if (!strcmp(name, "section") || !strcmp(name, "repo.group")) ctx.cfg.section = xstrdup(value); else if (!strcmp(name, "repo.url")) ctx.repo = cgit_add_repo(value); else if (ctx.repo && !strcmp(name, "repo.path")) ctx.repo->path = trim_end(value, '/'); - else if (ctx.repo && starts_with(name, "repo.")) - repo_config(ctx.repo, name + 5, value); + else if (ctx.repo && skip_prefix(name, "repo.", &arg)) + repo_config(ctx.repo, arg, value); else if (!strcmp(name, "readme")) string_list_append(&ctx.cfg.readme, xstrdup(value)); else if (!strcmp(name, "root-title")) @@ -280,8 +283,8 @@ static void config_cb(const char *name, const char *value) ctx.cfg.branch_sort = 1; if (!strcmp(value, "name")) ctx.cfg.branch_sort = 0; - } else if (starts_with(name, "mimetype.")) - add_mimetype(name + 9, value); + } else if (skip_prefix(name, "mimetype.", &arg)) + add_mimetype(arg, value); else if (!strcmp(name, "include")) parse_configfile(expand_macros(value), config_cb); } @@ -470,13 +473,13 @@ static char *find_default_branch(struct cgit_repo *repo) static char *guess_defbranch(void) { - const char *ref; + const char *ref, *refname; unsigned char sha1[20]; ref = resolve_ref_unsafe("HEAD", 0, sha1, NULL); - if (!ref || !starts_with(ref, "refs/heads/")) + if (!ref || !skip_prefix(ref, "refs/heads/", &refname)) return "master"; - return xstrdup(ref + 11); + return xstrdup(refname); } /* The caller must free filename and ref after calling this. */ static inline void parse_readme(const char *readme, char **filename, char **ref, struct cgit_repo *repo) @@ -937,6 +940,7 @@ out: static void cgit_parse_args(int argc, const char **argv) { int i; + const char *arg; int scan = 0; for (i = 1; i < argc; i++) { @@ -957,28 +961,28 @@ static void cgit_parse_args(int argc, const char **argv) exit(0); } - if (starts_with(argv[i], "--cache=")) { - ctx.cfg.cache_root = xstrdup(argv[i] + 8); + if (skip_prefix(argv[i], "--cache=", &arg)) { + ctx.cfg.cache_root = xstrdup(arg); } else if (!strcmp(argv[i], "--nocache")) { ctx.cfg.nocache = 1; } else if (!strcmp(argv[i], "--nohttp")) { ctx.env.no_http = "1"; - } else if (starts_with(argv[i], "--query=")) { - ctx.qry.raw = xstrdup(argv[i] + 8); - } else if (starts_with(argv[i], "--repo=")) { - ctx.qry.repo = xstrdup(argv[i] + 7); - } else if (starts_with(argv[i], "--page=")) { - ctx.qry.page = xstrdup(argv[i] + 7); - } else if (starts_with(argv[i], "--head=")) { - ctx.qry.head = xstrdup(argv[i] + 7); + }
[PATCH] Simplify http_parse_querystring()
Instead of reimplementing URL parameter parsing from scratch, use url_decode_parameter_name() and url_decode_parameter_value() which are already provided by Git. Also, change the return type of http_parse_querystring() to void since its only caller already ignores the return value. Signed-off-by: Lukas Fleischer --- html.c | 66 ++ html.h | 2 +- 2 files changed, 11 insertions(+), 57 deletions(-) diff --git a/html.c b/html.c index d89df3a..e7e6e07 100644 --- a/html.c +++ b/html.c @@ -8,6 +8,7 @@ #include "cgit.h" #include "html.h" +#include "url.h" /* Percent-encoding of each character, except: a-zA-Z0-9!$()*,./:;@- */ static const char* url_escape_table[256] = { @@ -337,64 +338,17 @@ int html_include(const char *filename) return 0; } -static int hextoint(char c) +void http_parse_querystring(const char *txt, void (*fn)(const char *name, const char *value)) { - if (c >= 'a' && c <= 'f') - return 10 + c - 'a'; - else if (c >= 'A' && c <= 'F') - return 10 + c - 'A'; - else if (c >= '0' && c <= '9') - return c - '0'; - else - return -1; -} - -static char *convert_query_hexchar(char *txt) -{ - int d1, d2, n; - n = strlen(txt); - if (n < 3) { - *txt = '\0'; - return txt-1; - } - d1 = hextoint(*(txt + 1)); - d2 = hextoint(*(txt + 2)); - if (d1 < 0 || d2 < 0) { - memmove(txt, txt + 3, n - 2); - return txt-1; - } else { - *txt = d1 * 16 + d2; - memmove(txt + 1, txt + 3, n - 2); - return txt; - } -} + const char *t = txt; -int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const char *value)) -{ - char *o, *t, *txt, *value = NULL, c; - - if (!txt_) - return 0; - - o = t = txt = xstrdup(txt_); - while ((c=*t) != '\0') { - if (c == '=') { - *t = '\0'; - value = t + 1; - } else if (c == '+') { - *t = ' '; - } else if (c == '%') { - t = convert_query_hexchar(t); - } else if (c == '&') { - *t = '\0'; - (*fn)(txt, value); - txt = t + 1; - value = NULL; + while (t && *t) { + char *name = url_decode_parameter_name(&t); + if (*name) { + char *value = url_decode_parameter_value(&t); + fn(name, value); + free(value); } - t++; + free(name); } - if (t != txt) - (*fn)(txt, value); - free(o); - return 0; } diff --git a/html.h b/html.h index c72e845..1b24e55 100644 --- a/html.h +++ b/html.h @@ -32,6 +32,6 @@ extern void html_link_close(void); extern void html_fileperm(unsigned short mode); extern int html_include(const char *filename); -extern int http_parse_querystring(const char *txt, void (*fn)(const char *name, const char *value)); +extern void http_parse_querystring(const char *txt, void (*fn)(const char *name, const char *value)); #endif /* HTML_H */ -- 2.10.0 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Avoid ambiguities when prettifying snapshot names
On Tue, 24 May 2016 at 18:15:18, Lukas Fleischer wrote: > When composing snapshot file names for a tag with a prefix of the form > v[0-9] (resp. V[0-9]), the leading "v" (resp. "V") is stripped. This > leads to conflicts if a tag with the stripped name already exists or if > there are tags only differing in the capitalization of the leading "v". > Make sure we do not strip the "v" in these cases. > > Reported-by: Juuso Lapinlampi > Signed-off-by: Lukas Fleischer > --- > Note: The code that actually generates the snapshots works fine as it > always tries an exact match first. > > ui-refs.c | 24 +--- > ui-shared.c | 26 +- > ui-shared.h | 2 ++ > 3 files changed, 32 insertions(+), 20 deletions(-) Any comments on this? ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Avoid ambiguities when prettifying snapshot names
When composing snapshot file names for a tag with a prefix of the form v[0-9] (resp. V[0-9]), the leading "v" (resp. "V") is stripped. This leads to conflicts if a tag with the stripped name already exists or if there are tags only differing in the capitalization of the leading "v". Make sure we do not strip the "v" in these cases. Reported-by: Juuso Lapinlampi Signed-off-by: Lukas Fleischer --- Note: The code that actually generates the snapshots works fine as it always tries an exact match first. ui-refs.c | 24 +--- ui-shared.c | 26 +- ui-shared.h | 2 ++ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/ui-refs.c b/ui-refs.c index 5b4530e..75f2789 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -93,34 +93,28 @@ static void print_tag_header(void) static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) { const struct cgit_snapshot_format* f; - struct strbuf filename = STRBUF_INIT; const char *basename; - int free_ref = 0; + struct strbuf filename = STRBUF_INIT; + size_t prefixlen; if (!ref || strlen(ref) < 1) return; basename = cgit_repobasename(repo->url); - if (!starts_with(ref, basename)) { - if ((ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1])) - ref++; - if (isdigit(ref[0])) { - ref = fmtalloc("%s-%s", basename, ref); - free_ref = 1; - } - } - + if (starts_with(ref, basename)) + strbuf_addstr(&filename, ref); + else + cgit_compose_snapshot_prefix(&filename, basename, ref); + prefixlen = filename.len; for (f = cgit_snapshot_formats; f->suffix; f++) { if (!(repo->snapshots & f->bit)) continue; - strbuf_reset(&filename); - strbuf_addf(&filename, "%s%s", ref, f->suffix); + strbuf_setlen(&filename, prefixlen); + strbuf_addstr(&filename, f->suffix); cgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL, filename.buf); html(" "); } - if (free_ref) - free((char *)ref); strbuf_release(&filename); } diff --git a/ui-shared.c b/ui-shared.c index 2c88b72..1c449f3 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1069,18 +1069,34 @@ void cgit_print_filemode(unsigned short mode) html_fileperm(mode); } +void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base, + const char *ref) +{ + unsigned char sha1[20]; + + /* +* Prettify snapshot names by stripping leading "v" or "V" if the tag +* name starts with {v,V}[0-9] and the prettify mapping is injective, +* i.e. each stripped tag can be inverted without ambiguities. +*/ + if (get_sha1(fmt("refs/tags/%s", ref), sha1) == 0 && + (ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) && + ((get_sha1(fmt("refs/tags/%s", ref + 1), sha1) == 0) + +(get_sha1(fmt("refs/tags/v%s", ref + 1), sha1) == 0) + +(get_sha1(fmt("refs/tags/V%s", ref + 1), sha1) == 0) == 1)) + ref++; + + strbuf_addf(filename, "%s-%s", base, ref); +} + void cgit_print_snapshot_links(const char *repo, const char *head, const char *hex, int snapshots) { const struct cgit_snapshot_format* f; struct strbuf filename = STRBUF_INIT; size_t prefixlen; - unsigned char sha1[20]; - if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 && - (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1])) - hex++; - strbuf_addf(&filename, "%s-%s", cgit_repobasename(repo), hex); + cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo), hex); prefixlen = filename.len; for (f = cgit_snapshot_formats; f->suffix; f++) { if (!(snapshots & f->bit)) diff --git a/ui-shared.h b/ui-shared.h index b457c97..87799f1 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -71,6 +71,8 @@ __attribute__((format (printf,3,4))) extern void cgit_print_error_page(int code, const char *msg, const char *fmt, ...); extern void cgit_print_pageheader(void); extern void cgit_print_filemode(unsigned short mode); +extern void cgit_compose_snapshot_prefix(struct strbuf *filename, +const char *base, const char *ref); extern void cgit_print_snapshot_links(const char *repo, const char *head, const char *hex, int snapshots); extern void cgit_add_hidden_formfields(int incl_head, int incl_search, -- 2.8.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Fix segmentation fault in hc()
The ctx.qry.page variable might be unset at this point, e.g. when an invalid command is passed and cgit_print_pageheader() is called to show an error message. Signed-off-by: Lukas Fleischer --- ui-shared.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui-shared.c b/ui-shared.c index c04f380..6b78b91 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -889,6 +889,9 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, static const char *hc(const char *page) { + if (!ctx.qry.page) + return NULL; + return strcmp(ctx.qry.page, page) ? NULL : "active"; } -- 2.6.4 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Snapshot: Customize filename and remove obligatory folder
On Mon, 09 Nov 2015 at 13:11:51, Alexander Nitsche - e-pixler NEW MEDIA GmbH wrote: > It would be nice to be able to > > a) customize the automatically generated snapshot filename. In general > it is {repository_name}-{branch}.zip. I - for integrity reasons - need > to be able to say that the filename should be {filename_xy}.zip without > the branch and a different name than the repo name. In my particular > case this is for constraints of the CMS system Typo3. > [...] You should be able to achieve this by telling your web server to redirect the URI to the path that cgit uses. > b) remove the obligatory parent folder from the snapshot: e.g. if the > tree structure of the git project "my_typo3_extension" is > --- > /classes/ > /resources/ > /configuration/ > ext_emconf.php > ext_tables.php > .. > --- > then the snapshot zip file looks like > --- > /my_typo3_extension > /classes/ > /resources/ > /configuration/ > ext_emconf.php > ext_tables.php > .. > --- > but i need the snapshot to be without the parent folder > "my_typo3_extension" - for Typo3 constraints again. > [...] I don't think this is currently possible but patching cgit to support that should be fairly easy. Have a look at the prefix variable/parameter in ui-snapshot.c. Regards, Lukas ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Customize cgit for the AUR
On Thu, 04 Jun 2015 at 13:32:41, Lukas Fleischer wrote: > From: Lukas Fleischer > > * Mention "AUR" and the package base in the title. > * Remove the branch switch form. > * Do not show any commit decorations. > * Do not show branches on the summary page. > * Drop link to the "refs" page. > * Use proper Git clone URLs. > > Signed-off-by: Lukas Fleischer > --- > ui-commit.c | 1 - > ui-log.c | 1 - > ui-shared.c | 28 +++- > ui-summary.c | 2 -- > 4 files changed, 7 insertions(+), 25 deletions(-) > [...] Sorry for submitting this here. This is obviously the wrong mailing list... ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Customize cgit for the AUR
From: Lukas Fleischer * Mention "AUR" and the package base in the title. * Remove the branch switch form. * Do not show any commit decorations. * Do not show branches on the summary page. * Drop link to the "refs" page. * Use proper Git clone URLs. Signed-off-by: Lukas Fleischer --- ui-commit.c | 1 - ui-log.c | 1 - ui-shared.c | 28 +++- ui-summary.c | 2 -- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/ui-commit.c b/ui-commit.c index d5a888d..0c2c1f8 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -114,7 +114,6 @@ void cgit_print_commit(char *hex, const char *prefix) cgit_open_filter(ctx.repo->commit_filter); html_txt(info->subject); cgit_close_filter(ctx.repo->commit_filter); - show_commit_decorations(commit); html(""); html(""); cgit_open_filter(ctx.repo->commit_filter); diff --git a/ui-log.c b/ui-log.c index 32b4c47..f855138 100644 --- a/ui-log.c +++ b/ui-log.c @@ -166,7 +166,6 @@ static void print_commit(struct commit *commit, struct rev_info *revs) } cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, sha1_to_hex(commit->object.sha1), ctx.qry.vpath); - show_commit_decorations(commit); html(""); cgit_open_filter(ctx.repo->email_filter, info->author_email, "log"); html_txt(info->author); diff --git a/ui-shared.c b/ui-shared.c index ac5a287..377032e 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -786,10 +786,10 @@ static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix) void cgit_add_clone_urls(void (*fn)(const char *)) { - if (ctx.repo->clone_url) - add_clone_urls(fn, expand_macros(ctx.repo->clone_url), NULL); - else if (ctx.cfg.clone_prefix) - add_clone_urls(fn, ctx.cfg.clone_prefix, ctx.repo->url); + struct strbuf url = STRBUF_INIT; + + strbuf_addf(&url, "%s/%s.git/", ctx.cfg.clone_prefix, ctx.qry.head); + add_clone_urls(fn, strbuf_detach(&url, NULL), NULL); } static int print_branch_option(const char *refname, const unsigned char *sha1, @@ -886,21 +886,9 @@ static void print_header(void) html(""); if (ctx.repo) { - cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1); - html(" : "); - cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); - if (ctx.env.authenticated) { - html(""); - html("\n"); - cgit_add_hidden_formfields(0, 1, ctx.qry.page); - html("\n"); - for_each_branch_ref(print_branch_option, ctx.qry.head); - if (ctx.repo->enable_remote_branches) - for_each_remote_ref(print_branch_option, ctx.qry.head); - html(" "); - html(""); - html(""); - } + html_txt("AUR : "); + html_txt(ctx.qry.head); + html_txt(".git"); } else html_txt(ctx.cfg.root_title); html("\n"); @@ -933,8 +921,6 @@ void cgit_print_pageheader(void) NULL); cgit_summary_link("summary", NULL, hc("summary"), ctx.qry.head); - cgit_refs_link("refs", NULL, hc("refs"), ctx.qry.head, - ctx.qry.sha1, NULL); cgit_log_link("log", NULL, hc("log"), ctx.qry.head, NULL, ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg); diff --git a/ui-summary.c b/ui-summary.c index b0af073..e7ea890 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -50,8 +50,6 @@ void cgit_print_summary(void) columns++; html(""); - cgit_print_branches(ctx.cfg.summary_branches); - htmlf(" ", columns); cgit_print_tags(ctx.cfg.summary_tags); if (ctx.cfg.summary_log > 0) { htmlf(" ", columns); -- 2.4.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Add an option to disable the branch switch form
On Sat, 07 Feb 2015 at 17:33:36, Lukas Fleischer wrote: > Introduce a configuration option enable-switch-form that is enabled by > default and can be used to disable the branch quick switch form in the > top-right corner of repository pages. > > Rationale: For repositories with a huge number of branches, the code > generated for the switch form might become so large that it dominates > the size of the HTTP response. For example, at the time of writing this > commit message, the HTTP body of the Arch Linux community.git cgit index > at https://projects.archlinux.org/svntogit/community.git/ has a size of > 228KB. Removing the form shrinks the size to only 12KB. > > Signed-off-by: Lukas Fleischer > --- > I am not totally happy with the name but I did not come up with anything > more expressive that is short enough at the same time. Suggestions > welcome! > [...] Starting from next week, I am going to maintain another cgit setup where this patch is needed. Any chance this will make it into mainline? I am also open to other suggestions. Maybe a (configurable) limit for the number of entries in the branch switcher? Right now, cgit is unusable with a huge number of branches. Regards, Lukas ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Check SHA256 sum of git-$VER.tar.gz after downloading
On Sat, 07 Mar 2015 at 18:02:59, John Keeping wrote: > [...] > I'm not sure what benefit it has if it's optional. Will anyone check? > > Maybe we could do something like: > > if type sha256sum >/dev/null 2>&1 > then > sha256sum --check git.sha256sum $(GIT_FILE) > else > echo >&2 'WARNING: sha256sum not found so we cannot verify' > echo >&2 'WARNING: the integrity of the Git archive!' > fi > That is exactly what I meant by suggesting to make it optional. Sorry for being vague... > > On a related note, can we download a signature and use `gpg --verify` > > instead (should probably be optional as well, to avoid a dependency on > > GnuPG)? > > I thought about that, but we'd have to embed a key with CGit for it to > work reliably and how do we choose what key to use (given that > individual Git archives are not signed - the list of SHA256 checksums > is)? > Huh? This works fine for me: $ gpg --recv-keys 96AFE6CB gpg: key 713660A7: public key "Junio C Hamano " imported gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u gpg: Total number processed: 1 gpg: imported: 1 $ curl -OO https://www.kernel.org/pub/software/scm/git/git-2.3.2.tar.{xz,sign} % Total% Received % Xferd Average Speed TimeTime Time Current Dload Upload Total SpentLeft Speed 100 3529k 100 3529k0 0 1133k 0 0:00:03 0:00:03 --:--:-- 1133k 100 543 100 5430 0 3404 0 --:--:-- --:--:-- --:--:-- 3404 $ unxz git-2.3.2.tar.xz $ gpg --verify git-2.3.2.tar.sign gpg: assuming signed data in 'git-2.3.2.tar' gpg: Signature made Sat 07 Mar 2015 12:10:41 AM CET using RSA key ID 96AFE6CB gpg: Good signature from "Junio C Hamano " [unknown] gpg: aka "Junio C Hamano " [unknown] gpg: aka "Junio C Hamano " [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 96E0 7AF2 5771 9559 80DA D100 20D0 4E5A 7136 60A7 Subkey fingerprint: E1F0 36B1 FEE7 221F C778 ECEF B0B5 E886 96AF E6CB ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Check SHA256 sum of git-$VER.tar.gz after downloading
On Sat, 07 Mar 2015 at 15:46:41, John Keeping wrote: > This requires that we save the downloaded file explicitly rather than > piping it straight to tar, but that is advisable anyway since it allows > us to check the exit status of curl and make sure that we have > downloaded the file successfully. > > Also add a test to make sure we don't forget to update the file when > updating our Git version in the future. > > Signed-off-by: John Keeping > --- > Makefile | 8 ++-- > git.sha256sum| 1 + > tests/t0001-validate-git-versions.sh | 11 +++ > 3 files changed, 18 insertions(+), 2 deletions(-) > create mode 100644 git.sha256sum > [...] I like the idea, however, sha256sum is not available on all platforms. This breaks `make get-git` under OpenBSD, for example (OpenBSD has a utility called sha256 with a different command line interface). Maybe we can make the check optional, though? On a related note, can we download a signature and use `gpg --verify` instead (should probably be optional as well, to avoid a dependency on GnuPG)? ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Remove no-op link from submodule entries
Instead of linking to the current page ("href='#'"), do not add a link to a submodule entry at all if the module-link setting is not used. Signed-off-by: Lukas Fleischer --- cgit.css| 2 +- ui-shared.c | 41 - 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/cgit.css b/cgit.css index 6888cde..82c755c 100644 --- a/cgit.css +++ b/cgit.css @@ -254,7 +254,7 @@ div#cgit div.error { margin: 1em 2em; } -div#cgit a.ls-blob, div#cgit a.ls-dir, div#cgit a.ls-mod { +div#cgit a.ls-blob, div#cgit a.ls-dir, div#cgit .ls-mod { font-family: monospace; } diff --git a/ui-shared.c b/ui-shared.c index ff03cb2..c8c1ae0 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -555,25 +555,32 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) item = lookup_path(list, path); } } - html("module_link, dir, rev); + if (item || ctx.repo->module_link) { + html("module_link, dir, rev); + } + html("'>"); + html_txt(path); + html(""); } else { - html("#"); + html(""); + html_txt(path); + html(""); } - html("'>"); - html_txt(path); - html(""); html_txtf(" @ %.7s", rev); if (item && tail) path[len - 1] = tail; -- 2.3.1 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Support for submodules in tree view?
On Thu, 05 Mar 2015 at 19:25:53, John Keeping wrote: > On Thu, Mar 05, 2015 at 06:19:31PM +, Dunnigan, Terrence J wrote: > > We are using cgit 0.10.1. Some of our repos have submodules, and when > > I look at a tree view I see the name of the submodule with its current > > hash, e.g. > > > > m- Utilities @ 350bc94 > > > > The submodule names are all hyperlinks, but the actual link is just a > > "#". So clicking on it doesn't do anything. > > > > Is this the correct behavior? Or something on my system improperly > > configured to support submodules? > > You probably need to set the "module-link" configuration variable in > your cgitrc file. > > Since it's possible for submodules to link to a different server, there > isn't really much CGit can do in the general case. Note that there's > also "repo.module-link." in case your submodule paths don't match > up to their URLs, although I'm quite surprised we don't support a filter > to map submodule URLs to links - something to go on the TODO list > perhaps... What do you think about hiding the "#" link, though? I don't think it is a good idea to pretend there is a link when there isn't... -- >8 -- diff --git a/ui-shared.c b/ui-shared.c index ff03cb2..0eeab6f 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -555,25 +555,27 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) item = lookup_path(list, path); } } - html("module_link, dir, rev); + if (item || ctx.repo->module_link) { + html("module_link, dir, rev); + } + html("'>"); + html_txt(path); + html(""); } else { - html("#"); + html_txt(path); } - html("'>"); - html_txt(path); - html(""); html_txtf(" @ %.7s", rev); if (item && tail) path[len - 1] = tail; ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Support .git/category files
On Thu, 05 Mar 2015 at 18:15:04, Jan-Marek Glogowski wrote: > Gitweb reads .git/category to set a repository section for > grouping. This handles the file in the same way a .git/description > file is handled. > > The file section takes precedence over the ctx.cfg.section_from_path > setting. > --- > cgit.c | 2 +- > cgit.h | 1 + > scan-tree.c | 20 +++- > shared.c| 1 + > 4 files changed, 22 insertions(+), 2 deletions(-) > [...] There already are at least two ways to achieve the same thing (using the Git configuration variables gitweb.category or cgit.section and repository-specific cgitrc files). Do we really need another alternative? Is this just for GitWeb compatibility or does this have any advantages over the existing options? ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 2/2] Drop return value from parse_user()
In commit 936295c (Simplify commit and tag parsing, 2015-03-03), the commit and tag parsing code was refactored. This broke tag messages in ui-tag since the line after the tagger header was erroneously skipped. Rework parse_user() and skip the line manually outside parse_user(). Signed-off-by: Lukas Fleischer --- parsing.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/parsing.c b/parsing.c index dcaf2b3..f903c7c 100644 --- a/parsing.c +++ b/parsing.c @@ -69,13 +69,12 @@ static char *substr(const char *head, const char *tail) return buf; } -static const char *parse_user(const char *t, char **name, char **email, unsigned long *date) +static void parse_user(const char *t, char **name, char **email, unsigned long *date) { - const char *line_end = strchrnul(t, '\n'); struct ident_split ident; unsigned email_len; - if (!split_ident_line(&ident, t, line_end - t)) { + if (!split_ident_line(&ident, t, strchrnul(t, '\n') - t)) { *name = substr(ident.name_begin, ident.name_end); email_len = ident.mail_end - ident.mail_begin; @@ -85,11 +84,6 @@ static const char *parse_user(const char *t, char **name, char **email, unsigned if (ident.date_begin) *date = strtoul(ident.date_begin, NULL, 10); } - - if (*line_end) - return line_end + 1; - else - return line_end; } #ifdef NO_ICONV @@ -152,13 +146,15 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) p += sha1hex_len + 1; if (p && skip_prefix(p, "author ", &p)) { - p = parse_user(p, &ret->author, &ret->author_email, + parse_user(p, &ret->author, &ret->author_email, &ret->author_date); + p = next_header_line(p); } if (p && skip_prefix(p, "committer ", &p)) { - p = parse_user(p, &ret->committer, &ret->committer_email, + parse_user(p, &ret->committer, &ret->committer_email, &ret->committer_date); + p = next_header_line(p); } if (p && skip_prefix(p, "encoding ", &p)) { @@ -211,7 +207,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) for (p = data; !end_of_header(p); p = next_header_line(p)) { if (skip_prefix(p, "tagger ", &p)) { - p = parse_user(p, &ret->tagger, &ret->tagger_email, + parse_user(p, &ret->tagger, &ret->tagger_email, &ret->tagger_date); } } -- 2.3.1 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 1/2] Remove leading newline characters from tag messages
Fixes a regression introduced in commit 936295c (Simplify commit and tag parsing, 2015-03-03). Signed-off-by: Lukas Fleischer --- parsing.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parsing.c b/parsing.c index 0db181b..dcaf2b3 100644 --- a/parsing.c +++ b/parsing.c @@ -216,6 +216,9 @@ struct taginfo *cgit_parse_tag(struct tag *tag) } } + while (p && *p == '\n') + p++; + if (p && *p) ret->msg = xstrdup(p); -- 2.3.1 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Simplify commit and tag parsing
* Use skip_prefix to avoid magic numbers in the code. * Use xcalloc() instead of xmalloc(), followed by manual initialization. * Split out line splitting. Signed-off-by: Lukas Fleischer --- parsing.c | 114 +++--- 1 file changed, 42 insertions(+), 72 deletions(-) diff --git a/parsing.c b/parsing.c index 53c29bb..0db181b 100644 --- a/parsing.c +++ b/parsing.c @@ -118,45 +118,50 @@ static const char *reencode(char **txt, const char *src_enc, const char *dst_enc } #endif +static const char *next_header_line(const char *p) +{ + p = strchr(p, '\n'); + if (!p) + return NULL; + return p + 1; +} + +static int end_of_header(const char *p) +{ + return !p || (*p == '\n'); +} + struct commitinfo *cgit_parse_commit(struct commit *commit) { + const int sha1hex_len = 40; struct commitinfo *ret; const char *p = get_cached_commit_buffer(commit, NULL); const char *t; - ret = xmalloc(sizeof(*ret)); + ret = xcalloc(1, sizeof(struct commitinfo)); ret->commit = commit; - ret->author = NULL; - ret->author_email = NULL; - ret->committer = NULL; - ret->committer_email = NULL; - ret->subject = NULL; - ret->msg = NULL; - ret->msg_encoding = NULL; - - if (p == NULL) + + if (!p) return ret; - if (!starts_with(p, "tree ")) + if (!skip_prefix(p, "tree ", &p)) die("Bad commit: %s", sha1_to_hex(commit->object.sha1)); - else - p += 46; // "tree " + hex[40] + "\n" + p += sha1hex_len + 1; - while (starts_with(p, "parent ")) - p += 48; // "parent " + hex[40] + "\n" + while (skip_prefix(p, "parent ", &p)) + p += sha1hex_len + 1; - if (p && starts_with(p, "author ")) { - p = parse_user(p + 7, &ret->author, &ret->author_email, + if (p && skip_prefix(p, "author ", &p)) { + p = parse_user(p, &ret->author, &ret->author_email, &ret->author_date); } - if (p && starts_with(p, "committer ")) { - p = parse_user(p + 10, &ret->committer, &ret->committer_email, + if (p && skip_prefix(p, "committer ", &p)) { + p = parse_user(p, &ret->committer, &ret->committer_email, &ret->committer_date); } - if (p && starts_with(p, "encoding ")) { - p += 9; + if (p && skip_prefix(p, "encoding ", &p)) { t = strchr(p, '\n'); if (t) { ret->msg_encoding = substr(p, t + 1); @@ -164,38 +169,21 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) } } - /* if no special encoding is found, assume UTF-8 */ if (!ret->msg_encoding) ret->msg_encoding = xstrdup("UTF-8"); - // skip unknown header fields - while (p && *p && (*p != '\n')) { - p = strchr(p, '\n'); - if (p) - p++; - } - - // skip empty lines between headers and message + while (!end_of_header(p)) + p = next_header_line(p); while (p && *p == '\n') p++; - if (!p) return ret; - t = strchr(p, '\n'); - if (t) { - ret->subject = substr(p, t); - p = t + 1; - - while (p && *p == '\n') { - p = strchr(p, '\n'); - if (p) - p++; - } - if (p) - ret->msg = xstrdup(p); - } else - ret->subject = xstrdup(p); + t = strchrnul(p, '\n'); + ret->subject = substr(p, t); + while (*t == '\n') + t++; + ret->msg = xstrdup(t); reencode(&ret->author, ret->msg_encoding, PAGE_ENCODING); reencode(&ret->author_email, ret->msg_encoding, PAGE_ENCODING); @@ -207,49 +195,31 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) return ret; } - struct taginfo *cgit_parse_tag(struct tag *tag) { void *data; enum object_type type; unsigned long size; const char *p; - struct taginfo *ret; + struct taginfo *ret = NULL; data = read_sha1_file(tag->object.sha1, &type, &size);
[PATCH v2] ui-clone.c: Fix path check
The starts_with() check was broken in two ways: For one thing, the parameters were passed in the wrong order, for another thing, starts_with() returns 1 if the string starts with the prefix (not 0). Note that this bug existed since commit 02a545e (Add support for cloning over http, 2008-08-06) but only pops in in corner cases. Signed-off-by: Lukas Fleischer --- Using skip_prefix() might be even better here :) ui-clone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-clone.c b/ui-clone.c index 50569d6..1e6238d 100644 --- a/ui-clone.c +++ b/ui-clone.c @@ -63,8 +63,8 @@ static void send_file(char *path) } ctx.page.mimetype = "application/octet-stream"; ctx.page.filename = path; - if (!starts_with(ctx.repo->path, path)) - ctx.page.filename += strlen(ctx.repo->path) + 1; + skip_prefix(path, ctx.repo->path, &ctx.page.filename); + skip_prefix(ctx.page.filename, "/", &ctx.page.filename); cgit_print_http_headers(); html_include(path); } -- 2.3.0 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] ui-clone.c: Fix starts_with() path check
The check was broken in two ways: For one thing, the parameters were passed in the wrong order, for another thing, starts_with() returns 1 if the string starts with the prefix (not 0). Note that this bug existed since commit 02a545e (Add support for cloning over http, 2008-08-06) but only pops in in corner cases. Signed-off-by: Lukas Fleischer --- Jason, I stumbled across this when trying to reproduce the bug you reported earlier. Not sure if it is related but it's clearly a bug. One reason why we haven't seen this occur earlier is that it only manifests in a few rare cases (no packed refs, special requirements to repository paths). ui-clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-clone.c b/ui-clone.c index 50569d6..9b93459 100644 --- a/ui-clone.c +++ b/ui-clone.c @@ -63,7 +63,7 @@ static void send_file(char *path) } ctx.page.mimetype = "application/octet-stream"; ctx.page.filename = path; - if (!starts_with(ctx.repo->path, path)) + if (starts_with(path, ctx.repo->path)) ctx.page.filename += strlen(ctx.repo->path) + 1; cgit_print_http_headers(); html_include(path); -- 2.3.0 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Add an option to disable the branch switch form
Introduce a configuration option enable-switch-form that is enabled by default and can be used to disable the branch quick switch form in the top-right corner of repository pages. Rationale: For repositories with a huge number of branches, the code generated for the switch form might become so large that it dominates the size of the HTTP response. For example, at the time of writing this commit message, the HTTP body of the Arch Linux community.git cgit index at https://projects.archlinux.org/svntogit/community.git/ has a size of 228KB. Removing the form shrinks the size to only 12KB. Signed-off-by: Lukas Fleischer --- I am not totally happy with the name but I did not come up with anything more expressive that is short enough at the same time. Suggestions welcome! cgit.c | 6 ++ cgit.h | 2 ++ cgitrc.5.txt | 9 + shared.c | 1 + ui-shared.c | 2 +- 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cgit.c b/cgit.c index 431e325..58dd200 100644 --- a/cgit.c +++ b/cgit.c @@ -55,6 +55,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->enable_remote_branches = atoi(value); else if (!strcmp(name, "enable-subject-links")) repo->enable_subject_links = atoi(value); + else if (!strcmp(name, "enable-switch-form")) + repo->enable_switch_form = atoi(value); else if (!strcmp(name, "branch-sort")) { if (!strcmp(value, "age")) repo->branch_sort = 1; @@ -168,6 +170,8 @@ static void config_cb(const char *name, const char *value) ctx.cfg.enable_remote_branches = atoi(value); else if (!strcmp(name, "enable-subject-links")) ctx.cfg.enable_subject_links = atoi(value); + else if (!strcmp(name, "enable-switch-form")) + ctx.cfg.enable_switch_form = atoi(value); else if (!strcmp(name, "enable-tree-linenumbers")) ctx.cfg.enable_tree_linenumbers = atoi(value); else if (!strcmp(name, "enable-git-config")) @@ -362,6 +366,7 @@ static void prepare_context(void) ctx.cfg.enable_index_owner = 1; ctx.cfg.enable_tree_linenumbers = 1; ctx.cfg.enable_git_config = 0; + ctx.cfg.enable_switch_form = 1; ctx.cfg.max_repo_count = 50; ctx.cfg.max_commit_count = 50; ctx.cfg.max_lock_attempts = 5; @@ -824,6 +829,7 @@ static void print_repo(FILE *f, struct cgit_repo *repo) fprintf(f, "repo.logo-link=%s\n", repo->logo_link); fprintf(f, "repo.enable-remote-branches=%d\n", repo->enable_remote_branches); fprintf(f, "repo.enable-subject-links=%d\n", repo->enable_subject_links); + fprintf(f, "repo.enable-switch-form=%d\n", repo->enable_switch_form); if (repo->branch_sort == 1) fprintf(f, "repo.branch-sort=age\n"); if (repo->commit_sort) { diff --git a/cgit.h b/cgit.h index 16f8092..c3c56dd 100644 --- a/cgit.h +++ b/cgit.h @@ -96,6 +96,7 @@ struct cgit_repo { int enable_log_linecount; int enable_remote_branches; int enable_subject_links; + int enable_switch_form; int max_stats; int branch_sort; int commit_sort; @@ -229,6 +230,7 @@ struct cgit_config { int enable_log_linecount; int enable_remote_branches; int enable_subject_links; + int enable_switch_form; int enable_tree_linenumbers; int enable_git_config; int local_time; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index e21ece9..b99b787 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -186,6 +186,11 @@ enable-subject-links:: in commit view. Default value: "0". See also: "repo.enable-subject-links". +enable-switch-form:: + Flag which, when set to "1", will make cgit add a form to the top right + of each repository page that allows for quickly switching branches. + Default value: "1". See also: "repo.enable-switch-form". + enable-tree-linenumbers:: Flag which, when set to "1", will make cgit generate linenumber links for plaintext blobs printed in the tree view. Default value: "1". @@ -509,6 +514,10 @@ repo.enable-subject-links:: A flag which can be used to override the global setting `enable-subject-links'. Default value: none. +repo.enable-switch-form:: + A flag which can be used to override the global setting + `enable-switch-form'. Default value: none. + repo.hide:: Flag which, when set to "1", hides the repository from the repository index. The repository can still be accessed by providing a direct path. diff --git a/shared.c b/shared.c index ae17d
[PATCH] ui-shared.c: Refactor add_clone_urls()
Make use of strbuf_split_str() and strbuf lists to split clone URLs. Signed-off-by: Lukas Fleischer --- ui-shared.c | 32 ++-- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/ui-shared.c b/ui-shared.c index d8cc4d7..1a84afc 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -751,31 +751,19 @@ void cgit_print_docend() static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix) { - struct strbuf buf = STRBUF_INIT; - char *h = txt, *t, c; + struct strbuf **url_list = strbuf_split_str(txt, ' ', 0); + int i; - while (h && *h) { - while (h && *h == ' ') - h++; - if (!*h) - break; - t = h; - while (t && *t && *t != ' ') - t++; - c = *t; - *t = 0; - - if (suffix && *suffix) { - strbuf_reset(&buf); - strbuf_addf(&buf, "%s/%s", h, suffix); - h = buf.buf; - } - fn(h); - *t = c; - h = t; + for (i = 0; url_list[i]; i++) { + strbuf_rtrim(url_list[i]); + if (url_list[i]->len == 0) + continue; + if (suffix && *suffix) + strbuf_addf(url_list[i], "/%s", suffix); + fn(url_list[i]->buf); } - strbuf_release(&buf); + strbuf_list_free(url_list); } void cgit_add_clone_urls(void (*fn)(const char *)) -- 2.2.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Add repo.hide and repo.ignore
These options can be used to hide a repository from the index or completely ignore a repository, respectively. They are particularly useful when used in combination with scan-path. Signed-off-by: Lukas Fleischer --- cgit.c| 6 ++ cgit.h| 2 ++ cgitrc.5.txt | 10 ++ shared.c | 3 +++ ui-repolist.c | 2 ++ 5 files changed, 23 insertions(+) diff --git a/cgit.c b/cgit.c index 79019c2..431e325 100644 --- a/cgit.c +++ b/cgit.c @@ -93,6 +93,10 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->email_filter = cgit_new_filter(value, EMAIL); else if (!strcmp(name, "owner-filter")) repo->owner_filter = cgit_new_filter(value, OWNER); + } else if (!strcmp(name, "hide")) { + repo->hide = atoi(value); + } else if (!strcmp(name, "ignore")) { + repo->ignore = atoi(value); } } @@ -828,6 +832,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo) else if (repo->commit_sort == 2) fprintf(f, "repo.commit-sort=topo\n"); } + fprintf(f, "repo.hide=%d\n", repo->hide); + fprintf(f, "repo.ignore=%d\n", repo->ignore); fprintf(f, "\n"); } diff --git a/cgit.h b/cgit.h index 42140ac..16f8092 100644 --- a/cgit.h +++ b/cgit.h @@ -106,6 +106,8 @@ struct cgit_repo { struct cgit_filter *email_filter; struct cgit_filter *owner_filter; struct string_list submodules; + int hide; + int ignore; }; typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, diff --git a/cgitrc.5.txt b/cgitrc.5.txt index be6703f..e21ece9 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -509,6 +509,16 @@ repo.enable-subject-links:: A flag which can be used to override the global setting `enable-subject-links'. Default value: none. +repo.hide:: + Flag which, when set to "1", hides the repository from the repository + index. The repository can still be accessed by providing a direct path. + Default value: "0". See also: "repo.ignore". + +repo.ignore:: + Flag which, when set to "1", ignores the repository. The repository + is not shown in the index and cannot be accessed by providing a direct + path. Default value: "0". See also: "repo.hide". + repo.logo:: Url which specifies the source of an image which will be used as a logo on this repo's pages. Default value: global logo. diff --git a/shared.c b/shared.c index 6e91857..ae17d78 100644 --- a/shared.c +++ b/shared.c @@ -75,6 +75,7 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->owner_filter = ctx.cfg.owner_filter; ret->clone_url = ctx.cfg.clone_url; ret->submodules.strdup_strings = 1; + ret->hide = ret->ignore = 0; return ret; } @@ -85,6 +86,8 @@ struct cgit_repo *cgit_get_repoinfo(const char *url) for (i = 0; i < cgit_repolist.count; i++) { repo = &cgit_repolist.repos[i]; + if (repo->ignore) + continue; if (!strcmp(repo->url, url)) return repo; } diff --git a/ui-repolist.c b/ui-repolist.c index f929cb7..91911e0 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -275,6 +275,8 @@ void cgit_print_repolist() html(""); for (i = 0; i < cgit_repolist.count; i++) { ctx.repo = &cgit_repolist.repos[i]; + if (ctx.repo->hide || ctx.repo->ignore) + continue; if (!(is_match(ctx.repo) && is_in_url(ctx.repo))) continue; hits++; -- 2.2.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH v2] Support Git over HTTP using git-http-backend
On Mon, 19 Jan 2015 at 17:58:15, Jason A. Donenfeld wrote: > Do we really want to be enabling git-receive-pack? Seems like in its > present form, this could lead to some unexpected security results... > Not sure. But note that by default, git-receive-pack is not enabled. >From the git-http-backend(1) man page: By default, only the upload-pack service is enabled, which serves git fetch-pack and git ls-remote clients, which are invoked from git fetch, git pull, and git clone. If the client is authenticated, the receive-pack service is enabled, which serves git send-pack clients, which is invoked from git push. > More generally, is this the right approach? Since we're linking against > git's sources anyway, couldn't any enhanced functionality be included > within cgit by calling into the right functions in the git source? > Please check my reply to v2 of Florian's patch, almost everything in http-backend.c is static which makes this difficult. We would need to convince Junio (the current Git maintainer) to make those functions public and probably send patches to Git. I would say it is okay to merge this implementation now and eventually switch to direct function calls. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH v2] Support Git over HTTP using git-http-backend
On Mon, 19 Jan 2015 at 17:55:41, Jason A. Donenfeld wrote: > On Mon, Dec 29, 2014 at 5:56 PM, Florian Pritz wrote: > > > > +http-backend-path:: > > + Path to the git-http-backend smart HTTP backend binary. > > +http-backend-path=/usr/lib/git-core/git-http-backend > > > > Instead of all this, why not just a: > > execlp("git", "git", "http-backend", NULL); > > This leaves resolution to PATH and git's resolver, which should be more > coherent. > [...] Making it configurable allows for using another smart HTTP backend, though. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Add Etags for snapshots
From: Janus --- Sending this on behalf of Janus who cannot post to the list for some reason. ui-snapshot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui-snapshot.c b/ui-snapshot.c index ea77eb4..cb34f4b 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -119,6 +119,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, cgit_print_error("Not a commit reference: %s", hex); return 1; } + ctx.page.etag = sha1_to_hex(sha1); ctx.page.mimetype = xstrdup(format->mimetype); ctx.page.filename = xstrdup(filename); cgit_print_http_headers(); -- 2.2.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Return proper HTTP response when accessing info/
Currently, when a user directly accesses the info command of a repository, we exit cgit without printing anything to stdout, bringing up error messages like "502 Bad Gateway" or "An error occurred while reading CGI reply (no response received)". Instead of bailing out, at least print the HTTP headers, including a reasonable error message. Reported-by: Janus Troelsen Signed-off-by: Lukas Fleischer --- ui-clone.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui-clone.c b/ui-clone.c index a4ffd6e..50569d6 100644 --- a/ui-clone.c +++ b/ui-clone.c @@ -71,8 +71,10 @@ static void send_file(char *path) void cgit_clone_info(void) { - if (!ctx.qry.path || strcmp(ctx.qry.path, "refs")) + if (!ctx.qry.path || strcmp(ctx.qry.path, "refs")) { + html_status(400, "Bad request", 0); return; + } ctx.page.mimetype = "text/plain"; ctx.page.filename = "info/refs"; -- 2.2.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: log of tags
On Thu, 15 Jan 2015 at 17:18:02, Ferry Huberts wrote: > Hi > > Just noticed this: > You can't show the log of a tag when that tag is not on a branch, which > happen to me a lot for expired maintenance branches. > > Sound familiar? > > How to fix? > Include a 'log' line, like the 'Tagged object' line? > Or just make clicking on the log 'tab' do the right thing? (it currently > just shows the log of the default branch) > [...] Making the "log" link point to the log of the currently selected commit is easy but I do not know whether that is what we want to do. It is a convenient way to navigate back to the "full" log and I think this is what most users would expect. Note that you can always manually append "?id=$tag" to the log URI which is what I sometimes do when posting links to the log of a release somewhere. Anyway, if you still want the "make clicking on the log 'tab' do the right thing" behavior, try this (untested): -- >8 -- diff --git a/ui-shared.c b/ui-shared.c index 32f23f9..2eb0d4e 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -928,7 +928,7 @@ void cgit_print_pageheader(void) cgit_refs_link("refs", NULL, hc("refs"), ctx.qry.head, ctx.qry.sha1, NULL); cgit_log_link("log", NULL, hc("log"), ctx.qry.head, - NULL, ctx.qry.vpath, 0, NULL, NULL, + ctx.qry.sha1, ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg); cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head, ctx.qry.sha1, ctx.qry.vpath); ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH v2] Support Git over HTTP using git-http-backend
On Mon, 29 Dec 2014 at 17:56:05, Florian Pritz wrote: > This saves users from the hassle of setting up git-http-backend when > they already run cgit. > > References: man git-http-backend > > Signed-off-by: Florian Pritz > --- > > v2: > - git_root allocation was too small by 1 > - change comment style to c89 > > cgit.c | 3 +++ > cgit.h | 1 + > cgitrc.5.txt | 8 > cmd.c| 12 > ui-clone.c | 61 > > ui-clone.h | 2 ++ > 6 files changed, 87 insertions(+) > [...] Note that directly invoking http-backend from cgit without the overhead of execl() seems to be a bit more involved -- almost everything in http-backend.c is marked static: Acked-by: Lukas Fleischer ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 1/1] git: use xz compressed archive for download
On Wed, 24 Dec 2014 at 09:40:07, Jason A. Donenfeld wrote: > On Wed, Dec 24, 2014 at 1:01 AM, Lukas Fleischer > wrote: > > > > I don't think this is a good idea (I raised concerns weeks ago but > > forgot to Cc the mailing list). > > > > Shucks on the CC. > > > I'd like to hear more opinions. > *Who out there is deploying cgit on boxes that don't have tar's -J?* In case it wasn't obvious already: Me. OpenBSD's tar(1) does not support that option: tar: unknown option -- J usage: tar {crtux}[014578befHhjLmNOoPpqsvwXZz] [blocking-factor | archive | replstr] [-C directory] [-I file] [file ...] tar {-crtux} [-014578eHhjLmNOoPpqvwXZz] [-b blocking-factor] [-C directory] [-f archive] [-I file] [-s replstr] [file ...] Regards, Lukas ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 1/1] git: use xz compressed archive for download
On Wed, 24 Dec 2014 at 03:14:46, Jason A. Donenfeld wrote: > Merged a variant of this. > > xz is less commonly deployed, but I think modernization is a good thing in > this regard, so rolling with it. > I don't think this is a good idea (I raised concerns weeks ago but forgot to Cc the mailing list). Several tar(1) implementations don't support the -J switch. We could add some hackery and use the xz(1) command line utility instead but I am not sure whether the savings of ~30% justify portability hacks :) Either way, this should be reverted or replaced by something portable. Regards and happy holidays, Lukas ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH v2] Use split_ident_line() in parse_user()
Use Git's built-in ident line splitting algorithm instead of reimplementing it. This does not only simplify the code but also makes sure that cgit is consistent with Git when it comes to author parsing. Signed-off-by: Lukas Fleischer --- parsing.c | 45 + 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/parsing.c b/parsing.c index 3dbd122..53c29bb 100644 --- a/parsing.c +++ b/parsing.c @@ -71,36 +71,25 @@ static char *substr(const char *head, const char *tail) static const char *parse_user(const char *t, char **name, char **email, unsigned long *date) { - const char *p = t; - int mode = 1; + const char *line_end = strchrnul(t, '\n'); + struct ident_split ident; + unsigned email_len; - while (p && *p) { - if (mode == 1 && *p == '<') { - *name = substr(t, p - 1); - t = p; - mode++; - } else if (mode == 1 && *p == '\n') { - *name = substr(t, p); - p++; - break; - } else if (mode == 2 && *p == '>') { - *email = substr(t, p + 1); - t = p; - mode++; - } else if (mode == 2 && *p == '\n') { - *email = substr(t, p); - p++; - break; - } else if (mode == 3 && isdigit(*p)) { - *date = atol(p); - mode++; - } else if (*p == '\n') { - p++; - break; - } - p++; + if (!split_ident_line(&ident, t, line_end - t)) { + *name = substr(ident.name_begin, ident.name_end); + + email_len = ident.mail_end - ident.mail_begin; + *email = xmalloc(strlen("<") + email_len + strlen(">") + 1); + sprintf(*email, "<%.*s>", email_len, ident.mail_begin); + + if (ident.date_begin) + *date = strtoul(ident.date_begin, NULL, 10); } - return p; + + if (*line_end) + return line_end + 1; + else + return line_end; } #ifdef NO_ICONV -- 2.2.1 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Use split_ident_line() in parse_user()
On Wed, 24 Dec 2014 at 02:57:45, Jason A. Donenfeld wrote: > On Wed, Dec 17, 2014 at 5:19 AM, Lukas Fleischer > wrote: > > > Use Git's built-in ident line splitting algorithm instead of > > reimplementing it. This does not only simplify the code but also makes > > sure that cgit is consistent with Git when it comes to author parsing. > > > > Thank heavens! > > > + email_len = ident.mail_end - ident.mail_begin; > > + *email = xmalloc(strlen("<") + email_len + strlen(">\0")); > > + sprintf(*email, "<%.*s>", email_len, ident.mail_begin); > > + > > > > strlen(">\0") -- isn't the null superfluous? Cleanup and resubmit? I think this is even wrong because it means the buffer won't be large enough to hold the terminating null character. Will resubmit. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Use split_ident_line() in parse_user()
Use Git's built-in ident line splitting algorithm instead of reimplementing it. This does not only simplify the code but also makes sure that cgit is consistent with Git when it comes to author parsing. Signed-off-by: Lukas Fleischer --- I would also like to get rid of the angle brackets and only add them when displaying the information as HTML. That would also result in email filters getting email addresses without angle brackets which I consider to be a good thing but it breaks backwards compatibility. Any opinions on this are welcome. parsing.c | 45 + 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/parsing.c b/parsing.c index 3dbd122..7d34d11 100644 --- a/parsing.c +++ b/parsing.c @@ -71,36 +71,25 @@ static char *substr(const char *head, const char *tail) static const char *parse_user(const char *t, char **name, char **email, unsigned long *date) { - const char *p = t; - int mode = 1; + const char *line_end = strchrnul(t, '\n'); + struct ident_split ident; + unsigned email_len; - while (p && *p) { - if (mode == 1 && *p == '<') { - *name = substr(t, p - 1); - t = p; - mode++; - } else if (mode == 1 && *p == '\n') { - *name = substr(t, p); - p++; - break; - } else if (mode == 2 && *p == '>') { - *email = substr(t, p + 1); - t = p; - mode++; - } else if (mode == 2 && *p == '\n') { - *email = substr(t, p); - p++; - break; - } else if (mode == 3 && isdigit(*p)) { - *date = atol(p); - mode++; - } else if (*p == '\n') { - p++; - break; - } - p++; + if (!split_ident_line(&ident, t, line_end - t)) { + *name = substr(ident.name_begin, ident.name_end); + + email_len = ident.mail_end - ident.mail_begin; + *email = xmalloc(strlen("<") + email_len + strlen(">\0")); + sprintf(*email, "<%.*s>", email_len, ident.mail_begin); + + if (ident.date_begin) + *date = strtoul(ident.date_begin, NULL, 10); } - return p; + + if (*line_end) + return line_end + 1; + else + return line_end; } #ifdef NO_ICONV -- 2.1.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH v2] Remove trailing slash after remove-suffix
When removing the ".git" suffix of a non-bare repository, also remove the trailing slash for compatibility with cgit_repobasename(). Signed-off-by: Lukas Fleischer --- The previous version had a flaw (bogus pointer if there is no ".git" suffix). This one is much more readable add should be applied on top of the Git 2.2.0 patch (which adds strip_suffix() and strip_suffix_mem()). scan-tree.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scan-tree.c b/scan-tree.c index 044bcdc..e900ad9 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -123,9 +123,12 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) strbuf_setlen(path, pathlen); } - if (ctx.cfg.remove_suffix) - if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) - *p = '\0'; + if (ctx.cfg.remove_suffix) { + size_t urllen; + strip_suffix(repo->url, ".git", &urllen); + strip_suffix_mem(repo->url, &urllen, "/"); + repo->url[urllen] = '\0'; + } repo->path = xstrdup(path->buf); while (!repo->owner) { if ((pwd = getpwuid(st.st_uid)) == NULL) { -- 2.1.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Remove trailing slash after remove-suffix
When removing the ".git" suffix of a non-bare repository, also remove the trailing slash for compatibility with cgit_repobasename(). Signed-off-by: Lukas Fleischer --- scan-tree.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scan-tree.c b/scan-tree.c index 044bcdc..41e9264 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -123,9 +123,12 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) strbuf_setlen(path, pathlen); } - if (ctx.cfg.remove_suffix) + if (ctx.cfg.remove_suffix) { if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) *p = '\0'; + if (*(--p) == '/'); + *p = '\0'; + } repo->path = xstrdup(path->buf); while (!repo->owner) { if ((pwd = getpwuid(st.st_uid)) == NULL) { -- 2.1.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Should remove-suffix=1 and scan-path work with non-bare repos?
On Sat, 13 Dec 2014 at 09:41:34, Charles Dee Rice wrote: > [...] > and a non-bare repot /tmp/testing/blah/.git, I see unexpected behavior for > the "blah" repot. The repot is named "blah/" on the cgit index page (note > trailing slash). The Summary page for "blah/" works as expected, but > attempting to view any other data (refs, log, tree, etc), I receive a "No > repositories found" error. > [...] > Should scanning + remove-suffix work with non-bare repots? Please forgive me > if I have missed something simple -- I've been scratching my head on this for > a while. Am I doing something silly or missing something in the > documentation? > [...] While the trailing slash is technically correct, it does not look nice and does not match what we do in cgit_repobasename() -- so I consider this a bug. Could be please try the patch I am going to send in a second? Regards, Lukas ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Integration with Bugzilla?
On Fri, 24 Oct 2014 at 22:25:01, Joey Reid wrote: > Yes, rewording the scan-path section of cgitrc.5 and adding an entry to > the FAQ would be immensely helpful. > > The commit-links.sh and the trac script appear to spawn extra process. With > servers like FreeDesktop's cgit under a heavy load, is there a way > to minimize CPU usage? > [...] You can use Lua filters, check [1] for details. [1] http://git.zx2c4.com/cgit/tree/cgitrc.5.txt#n582 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 0/4] Add "stat only" diff mode
On Mon, 06 Oct 2014 at 05:01:41, Jason A. Donenfeld wrote: > Curious to know the motivation behind this patchset. Why would you want > stat-only? > [...] To avoid loading the whole diff when you're only interested in changes to a single file [1]. [1] http://lists.zx2c4.com/pipermail/cgit/2014-September/002235.html ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Integration with Bugzilla?
On Mon, 29 Sep 2014 at 20:33:28, Ferry Huberts wrote: > [...] > my server is guaranteed to have bash, so no need to change it. > but thanks for the hint anyway :-) > I am not (only) talking about portability here. My main concern is the current spate of bash vulnerabilities. As John pointed out earlier [1], these can be used to remotely exploit any cgit setup that uses a bash filter. We currently have at least five CVEs, some of which are very critical. So if you really want to use bash, you should at least closely follow the developments and always update your bash binary when there's a new security patch. > also, this script is a very minor modification of the script that's in > the source tree. > > -- > Ferry Huberts > [1] http://lists.zx2c4.com/pipermail/cgit/2014-September/002236.html ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Integration with Bugzilla?
On Mon, 29 Sep 2014 at 20:09:48, Ferry Huberts wrote: > [...] > #!/bin/bash > [...] This is a bit off topic but the script doesn't seem to rely on any bashisms (apart from the double brackets which can be ported easily), so it might be a good idea to use a "/bin/sh" shebang (and use a shell other than bash as "default shell") here? ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Integration with Bugzilla?
On Mon, 29 Sep 2014 at 19:49:09, Joey Reid wrote: > [...] > Is it possible to have cgit parse the subject for fdo# or > #i# and replace the plain text with a hyperlink containing > ? > [...] Yes, you can use the commit-filter option [1, 2]. There also is a very basic commit filter in the cgit source tree [3]. [1] http://git.zx2c4.com/cgit/tree/cgitrc.5.txt#n114 [2] http://git.zx2c4.com/cgit/tree/cgitrc.5.txt#n582 [3] http://git.zx2c4.com/cgit/tree/filters/commit-links.sh ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Always check if README exists in choose_readme()
Specifying a nonexistent README file via the readme option is sometimes useful, e.g. when using scan-path and setting a global default. Currently, we check whether there is only one option in the readme option and, if so, we choose that file without checking whether it exists. As a consequence, all repositories are equipped with an about link in the aforementioned scenario, even if there is no about file. Remove the early check for the number of keys and always check whether the file exists instead. Signed-off-by: Lukas Fleischer --- cgit.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/cgit.c b/cgit.c index 20f6e27..8c4517d 100644 --- a/cgit.c +++ b/cgit.c @@ -504,12 +504,6 @@ static void choose_readme(struct cgit_repo *repo) free(ref); continue; } - /* If there's only one item, we skip the possibly expensive -* selection process. */ - if (repo->readme.nr == 1) { - found = 1; - break; - } if (ref) { if (cgit_ref_path_exists(filename, ref, 1)) { found = 1; -- 2.0.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 1/1] git: update for git 2.0
On Sun, 04 May 2014 at 21:31:39, Christian Hesse wrote: > prefixcmp() and suffixcmp() have been remove, functionality is now > provided by starts_with() and ends_with(). Retrurn values have been > changed, so instead of just renaming we have to fix logic. > Everything else looks just fine. > --- > Makefile | 4 ++-- > cgit.c| 26 +- > git | 2 +- > parsing.c | 12 ++-- > scan-tree.c | 10 +++--- > ui-clone.c| 2 +- > ui-log.c | 8 > ui-refs.c | 6 +++--- > ui-repolist.c | 2 +- > ui-shared.c | 2 +- > ui-snapshot.c | 4 ++-- > ui-summary.c | 2 +- > 12 files changed, 42 insertions(+), 38 deletions(-) > > [...] > - else if (!prefixcmp(name, "module-link.")) { > + else if (starts_with(name, "module-link.")) { > item = string_list_append(&repo->submodules, xstrdup(name + > 12)); My original intention was to replace most of these with skip_prefix() (well, I actually wanted to wait for strip_prefix() to replace skip_prefix() but that didn't make it into Git 2.0). It would be great to see most of the starts_with() invocations (followed by hardcoded lengths) replaced by skip_prefix() but if you don't want to do it, I guess this change is okay for now. > item->util = xstrdup(value); > } else if (!strcmp(name, "section")) > @@ -102,7 +102,7 @@ static void config_cb(const char *name, const char *value) > ctx.repo = cgit_add_repo(value); > else if (ctx.repo && !strcmp(name, "repo.path")) > ctx.repo->path = trim_end(value, '/'); > - else if (ctx.repo && !prefixcmp(name, "repo.")) > + else if (ctx.repo && starts_with(name, "repo.")) > repo_config(ctx.repo, name + 5, value); > else if (!strcmp(name, "readme") && value != NULL) > string_list_append(&ctx.cfg.readme, xstrdup(value)); > @@ -264,7 +264,7 @@ static void config_cb(const char *name, const char *value) > [...] ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: kernel.org's libravatar lua script
On Fri, 14 Mar 2014 at 16:37:56, Konstantin Ryabitsev wrote: > Hi, all: > > We upgraded to 0.10.1 on kernel.org with libravatar support: > https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ > > As you'll notice, it's slightly different from the default gravatar > script, so here are our changes (using lua-md5 instead of luacrypto): > Nice. Note that this currently doesn't work when accessing the site via HTTP [1, 2]. > email-libravatar-korg.lua: > [...] [1] http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ [2] http://git.zx2c4.com/cgit/ ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: Intelligent caching
On Thu, 06 Feb 2014 at 20:55:14, Jason A. Donenfeld wrote: > This could be clever, if it's done properly. It'd have to be something > along the lines of "this page won't ever change, unless you can create an > sha1 hash collision", and we'd have to be certain that such pages then only > use information out of that sha1 object, and not additional related objects > that can be changed. > [...] I started to work on this. The main difficulty is that currently, the caching layer currently sits on top of prepare_repo_cmd() and is executed at a very early stage when there is no still no access to the Git repository. So before implementing this, I guess that we should check whether the caching mechanism can be moved without performance impacts (someone needs to review the code and benchmark this). For now, I will just merge the patches that have been sitting in lf/staging for several days. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: adopting kernel.org's css modifications?
On Thu, 20 Feb 2014 at 20:23:56, Jason A. Donenfeld wrote: > Looks like kernel.org makes some changes. Do we want to adopt any of > these? Some of them are pretty, like the even/odd background. Others > I'm not sure what they do... > [...] On the even/odd background (didn't check the other changes): I think that one looks good when having a lot of repositories and doesn't look good when having only a few of them. I also think that it is a bit weird that the "Clone" row is sometimes highlighted, see e.g. [1]. Anyway, it is just a default style so I don't care a lot. [1] https://git.kernel.org/cgit/bluetooth/sbc.git/ ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 1/1] print download link for reference string length == 1
On Thu, 20 Feb 2014 at 20:58:53, Christian Hesse wrote: > Christian Hesse on Thu, 2014/02/20 20:48: > > I have a number of repositories that start tagging with just '1' and > > count up. Actually references with sting length of one are skipped, this > > patch changes that. > > Wondering if there was a good reason to use a minimum string length of two... > Can my patch break anything? As far as I can tell is works without problems > for me. I can only guess because this code was added when the function was introduced in commit 65962685 (ui-refs.c: show download links for all tags referring to commit objects, 2008-12-01). I think it is related to the code below accessing ref[1], though. I don't see how anything could go wrong when the string length is 1 since isdigit('\0') should return 0 in that case. +1 from me. > -- > main(a){char*c=/*Schoene Gruesse */"B?IJj;MEH" > "CX:;",b;for(a/*Chris get my mail address:*/=0;b=c[a++];) > putchar(b-1/(/* gcc -o sig sig.c && ./sig*/b/42*2-3)*42);} > > > ___ > CGit mailing list > CGit@lists.zx2c4.com > http://lists.zx2c4.com/mailman/listinfo/cgit ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Skip cache slot when time-to-live is zero
On Thu, 20 Feb 2014 at 20:59:22, Lukas Fleischer wrote: > [...] > diff --git a/cgitrc.5.txt b/cgitrc.5.txt > index a437fc4..7158c10 100644 > --- a/cgitrc.5.txt > +++ b/cgitrc.5.txt > @@ -61,37 +61,43 @@ cache-root:: > cache-static-ttl:: > Number which specifies the time-to-live, in minutes, for the cached > version of repository pages accessed with a fixed SHA1. Negative > - values have infinite ttl. Default value: -1". > + values have infinite ttl, zero means that the cache is disabled for > + this type of pages. Default value: -1". Suggestions for better wording welcome, by the way. I also think that the already existing text "Negative values have infinite ttl" sounds a bit strange. Opinions? > [...] ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] git: Update to 1.9.0
On Thu, 20 Feb 2014 at 20:58:13, Lukas Fleischer wrote: > No code changes required, just bump the submodule and Makefile versions. > > Signed-off-by: Lukas Fleischer > --- > Makefile | 2 +- > git | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > Sorry, I really wrote this before reading the other thread. Feel free to either apply this, drop it or replace it with some patch by Christian. > diff --git a/Makefile b/Makefile > index 05b97d7..3ee5f65 100644 > --- a/Makefile > +++ b/Makefile > @@ -14,7 +14,7 @@ htmldir = $(docdir) > pdfdir = $(docdir) > mandir = $(prefix)/share/man > SHA1_HEADER = > -GIT_VER = 1.8.5 > +GIT_VER = 1.9.0 > GIT_URL = https://git-core.googlecode.com/files/git-$(GIT_VER).tar.gz > INSTALL = install > COPYTREE = cp -r > diff --git a/git b/git > index d2446df..5f95c9f 16 > --- a/git > +++ b/git > @@ -1 +1 @@ > -Subproject commit d2446dfd7f3b3f8948142cfb07a0270e2497d93f > +Subproject commit 5f95c9f850b19b368c43ae399cc831b17a26a5ac > -- > 1.9.0 > > ___ > CGit mailing list > CGit@lists.zx2c4.com > http://lists.zx2c4.com/mailman/listinfo/cgit ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Skip cache slot when time-to-live is zero
If time-to-live is set to zero, we don't need to regenerate the cache slots on every request. Instead, just skip the caching process and immediately provide the dynamically generated version of the page. Setting time-to-live to zero is useful when you want to disable caching for certain pages. Signed-off-by: Lukas Fleischer --- cache.c | 2 +- cgitrc.5.txt | 22 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cache.c b/cache.c index 9e7eeb0..801e63f 100644 --- a/cache.c +++ b/cache.c @@ -343,7 +343,7 @@ int cache_process(int size, const char *path, const char *key, int ttl, int result; /* If the cache is disabled, just generate the content */ - if (size <= 0) { + if (size <= 0 || ttl == 0) { fn(); return 0; } diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a437fc4..7158c10 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -61,37 +61,43 @@ cache-root:: cache-static-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of repository pages accessed with a fixed SHA1. Negative - values have infinite ttl. Default value: -1". + values have infinite ttl, zero means that the cache is disabled for + this type of pages. Default value: -1". cache-dynamic-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of repository pages accessed without a fixed SHA1. Negative - values have infinite ttl. Default value: "5". + values have infinite ttl, zero means that the cache is disabled for this + type of pages. Default value: "5". cache-repo-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository summary page. Negative values have infinite - ttl. Default value: "5". + ttl, zero means that the cache is disabled for this type of pages. + Default value: "5". cache-root-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository index page. Negative values have infinite - ttl. Default value: "5". + ttl, zero means that the cache is disabled for this type of pages. + Default value: "5". cache-scanrc-ttl:: Number which specifies the time-to-live, in minutes, for the result of scanning a path for git repositories. Negative values have infinite - ttl. Default value: "15". + ttl, zero means that the cache is disable for this type of pages. + Default value: "15". cache-about-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository about page. Negative values have infinite - ttl. Default value: "15". + ttl, zero means that the cache is disable for this type of pages. + Default value: "15". cache-snapshot-ttl:: Number which specifies the time-to-live, in minutes, for the cached - version of snapshots. Negative values have infinite ttl. Default - value: "5". + version of snapshots. Negative values have infinite ttl, zero means + that the cache is disable for this type of pages. Default value: "5". cache-size:: The maximum number of entries in the cgit cache. Default value: "0" -- 1.9.0 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] git: Update to 1.9.0
No code changes required, just bump the submodule and Makefile versions. Signed-off-by: Lukas Fleischer --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 05b97d7..3ee5f65 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 1.8.5 +GIT_VER = 1.9.0 GIT_URL = https://git-core.googlecode.com/files/git-$(GIT_VER).tar.gz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index d2446df..5f95c9f 16 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit d2446dfd7f3b3f8948142cfb07a0270e2497d93f +Subproject commit 5f95c9f850b19b368c43ae399cc831b17a26a5ac -- 1.9.0 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 1/2] Skip cache slot when time-to-live is zero
On Sat, 08 Feb 2014 at 14:41:56, Jason A. Donenfeld wrote: > > On Feb 6, 2014 10:07 PM, "Lukas Fleischer" wrote: > > > > This is different. -1 means "never expire". 0 means "always expire". > > Ahh perfect -- this is exactly the type of distinction I was looking for. > Do we have this documented? Yes, -1 is documented in the man page and it is quite clear that 0 means "always expire" (directly follows from the general description of what the *-ttl variables do). ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 2/2] Add a cache-snapshot-ttl configuration variable
On Wed, 05 Feb 2014 at 16:09:14, Lukas Fleischer wrote: > On Wed, 05 Feb 2014 at 15:44:36, Jason A. Donenfeld wrote: > [...] > > Currently it defaults to cache_repo_ttl, which is 5. I'd be willing to > > compromise for 15 if you prefer. > > I'm fine with either one. Whatever you prefer. Changed the default value to 5 in lf/staging. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Remove unused parameter from cgit_print_snapshot()
Signed-off-by: Lukas Fleischer --- cmd.c | 2 +- ui-snapshot.c | 2 +- ui-snapshot.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd.c b/cmd.c index cbd235c..188cd56 100644 --- a/cmd.c +++ b/cmd.c @@ -113,7 +113,7 @@ static void refs_fn(void) static void snapshot_fn(void) { cgit_print_snapshot(ctx.qry.head, ctx.qry.sha1, ctx.qry.path, - ctx.repo->snapshots, ctx.qry.nohead); + ctx.qry.nohead); } static void stats_fn(void) diff --git a/ui-snapshot.c b/ui-snapshot.c index 582dc31..3107b05 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -193,7 +193,7 @@ static void show_error(char *fmt, ...) } void cgit_print_snapshot(const char *head, const char *hex, -const char *filename, int snapshots, int dwim) +const char *filename, int dwim) { const struct cgit_snapshot_format* f; char *prefix = NULL; diff --git a/ui-snapshot.h b/ui-snapshot.h index b6ede52..a8deec3 100644 --- a/ui-snapshot.h +++ b/ui-snapshot.h @@ -2,6 +2,6 @@ #define UI_SNAPSHOT_H extern void cgit_print_snapshot(const char *head, const char *hex, - const char *filename, int snapshot, int dwim); + const char *filename, int dwim); #endif /* UI_SNAPSHOT_H */ -- 1.8.5.4 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 1/2] Skip cache slot when time-to-live is zero
On Thu, 06 Feb 2014 at 20:52:46, Jason A. Donenfeld wrote: > On Wed, Feb 5, 2014 at 10:46 AM, Lukas Fleischer wrote: > > > > /* If the cache is disabled, just generate the content */ > > - if (size <= 0) { > > + if (size <= 0 || ttl == 0) { > > fn(); > > return 0; > > } > > > Apparently we already special case ttl for < 0: > > /* Check if the slot has expired */ > static int is_expired(struct cache_slot *slot) > { > if (slot->ttl < 0) > return 0; > else > return slot->cache_st.st_mtime + slot->ttl * 60 < > time(NULL); > } > > What should our behavior be for consistency? This is different. -1 means "never expire". 0 means "always expire". We cannot add the 0 special case to is_expired(), though, because that would mean we would update and write the cache file to disk on every request which seems to be a bad idea (actually, that is what already happens now without having a special case). ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 2/2] Add a cache-snapshot-ttl configuration variable
On Wed, 05 Feb 2014 at 15:44:36, Jason A. Donenfeld wrote: > On Wed, Feb 5, 2014 at 10:46 AM, Lukas Fleischer wrote: > > This can be used to specify the TTL for snapshots. Snapshots are usually > > static and do not ever change. On the other hand, tarball generation is > > CPU intensive. > > > > One use case of this setting (apart from increasing the lifetime of > > snapshot cache slots) is caching of snapshots while disabling the cache > > for static/dynamic HTML pages (by setting TTL to zero for everything > > except for snapshot requests). > > > > I like this idea. But I don't think the default should be -1, since > that significantly changes the current behavior, and makes certain > tarballs get out of date perpetually, like downloading a zip of HEAD > or what happens when history is rewritten. Right, I didn't think of that. Only thought of the main use case which is downloading tagged snapshots. These are unlikely to change. I really wish we had some kind of intelligent caching as described in [1]. Using that, we could unquestionably use -1 as default everywhere. > > Currently it defaults to cache_repo_ttl, which is 5. I'd be willing to > compromise for 15 if you prefer. I'm fine with either one. Whatever you prefer. [1] http://lists.zx2c4.com/pipermail/cgit/2014-February/001974.html ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Intelligent caching
Hi, Reading through our caching code, I wondered why we don't make it a bit more clever. For every dynamically created page, we could just store a fingerprint that can be computed quite fast and indicates whether the cache slot is still up-to-date or not. For example, on the log pages, we could save the commit the corresponding ref points to and invalidate the cache slot when the ref has changed. Using that, we could use the power of caching and never deliver outdated pages at the same time. What do you think about that? Regards, Lukas ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 0/2] Add an option to cache snapshots
It seems strange that one can only enable caching of both HTML pages and snapshots or disable it for both. This patch series addresses this shortcoming and allows for more fine-grained control over what is cached. I find this quite useful on my cgit setups where I usually do not want to enable caching of HTML pages. Lukas Fleischer (2): Skip cache slot when time-to-live is zero Add a cache-snapshot-ttl configuration variable cache.c | 2 +- cgit.c | 6 ++ cgit.h | 1 + cgitrc.5.txt | 5 + 4 files changed, 13 insertions(+), 1 deletion(-) -- 1.8.5.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 2/2] Add a cache-snapshot-ttl configuration variable
This can be used to specify the TTL for snapshots. Snapshots are usually static and do not ever change. On the other hand, tarball generation is CPU intensive. One use case of this setting (apart from increasing the lifetime of snapshot cache slots) is caching of snapshots while disabling the cache for static/dynamic HTML pages (by setting TTL to zero for everything except for snapshot requests). Signed-off-by: Lukas Fleischer --- cgit.c | 6 ++ cgit.h | 1 + cgitrc.5.txt | 5 + 3 files changed, 12 insertions(+) diff --git a/cgit.c b/cgit.c index 36251e7..1ca5735 100644 --- a/cgit.c +++ b/cgit.c @@ -184,6 +184,8 @@ static void config_cb(const char *name, const char *value) ctx.cfg.cache_dynamic_ttl = atoi(value); else if (!strcmp(name, "cache-about-ttl")) ctx.cfg.cache_about_ttl = atoi(value); + else if (!strcmp(name, "cache-snapshot-ttl")) + ctx.cfg.cache_snapshot_ttl = atoi(value); else if (!strcmp(name, "case-sensitive-sort")) ctx.cfg.case_sensitive_sort = atoi(value); else if (!strcmp(name, "about-filter")) @@ -331,6 +333,7 @@ static void prepare_context(void) ctx.cfg.cache_max_create_time = 5; ctx.cfg.cache_root = CGIT_CACHE_ROOT; ctx.cfg.cache_about_ttl = 15; + ctx.cfg.cache_snapshot_ttl = -1; ctx.cfg.cache_repo_ttl = 5; ctx.cfg.cache_root_ttl = 5; ctx.cfg.cache_scanrc_ttl = 15; @@ -995,6 +998,9 @@ static int calc_ttl() if (!strcmp(ctx.qry.page, "about")) return ctx.cfg.cache_about_ttl; + if (!strcmp(ctx.qry.page, "snapshot")) + return ctx.cfg.cache_snapshot_ttl; + if (ctx.qry.has_sha1) return ctx.cfg.cache_static_ttl; diff --git a/cgit.h b/cgit.h index 496d0f6..0badc64 100644 --- a/cgit.h +++ b/cgit.h @@ -210,6 +210,7 @@ struct cgit_config { int cache_scanrc_ttl; int cache_static_ttl; int cache_about_ttl; + int cache_snapshot_ttl; int case_sensitive_sort; int embedded; int enable_filter_overrides; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 8eafc4a..33929f5 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -88,6 +88,11 @@ cache-about-ttl:: version of the repository about page. Negative values have infinite ttl. Default value: "15". +cache-snapshot-ttl:: + Number which specifies the time-to-live, in minutes, for the cached + version of snapshots. Negative values have infinite ttl. Default + value: "-1". + cache-size:: The maximum number of entries in the cgit cache. Default value: "0" (i.e. caching is disabled). -- 1.8.5.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 1/2] Skip cache slot when time-to-live is zero
If time-to-live is set to zero, we don't need to regenerate the cache slots on every request. Instead, just skip the caching process and immediately provide the dynamically generated version of the page. Setting time-to-live to zero is useful when you want to disable caching for certain pages. Signed-off-by: Lukas Fleischer --- cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache.c b/cache.c index 9e7eeb0..801e63f 100644 --- a/cache.c +++ b/cache.c @@ -343,7 +343,7 @@ int cache_process(int size, const char *path, const char *key, int ttl, int result; /* If the cache is disabled, just generate the content */ - if (size <= 0) { + if (size <= 0 || ttl == 0) { fn(); return 0; } -- 1.8.5.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] ui-refs.c: Simplify and inline cmp_age()
On Tue, 04 Feb 2014 at 20:27:56, Lukas Fleischer wrote: > On Tue, 04 Feb 2014 at 20:26:32, Jason A. Donenfeld wrote: > [...] > > cmp_age(-1, 0) returns -1 > > > > 0 - -1 returns 1 > > Can the age ever be negative? The age parameters can only contain copies of the committer_date or tagger_date fields which are unsigned. So I guess the patch is fine. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] ui-refs.c: Simplify and inline cmp_age()
On Tue, 04 Feb 2014 at 20:26:32, Jason A. Donenfeld wrote: > On Tue, Feb 4, 2014 at 8:22 PM, Lukas Fleischer wrote: > > > > return age2 - age1; > > -static int cmp_age(int age1, int age2) > > -{ > > - if (age1 != 0 && age2 != 0) > > - return age2 - age1; > > - > > - if (age1 == 0 && age2 == 0) > > - return 0; > > - > > - if (age1 == 0) > > - return +1; > > - > > - return -1; > > -} > > > cmp_age(-1, 0) returns -1 > > 0 - -1 returns 1 Can the age ever be negative? ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] ui-refs.c: Simplify and inline cmp_age()
In comparison functions, only the sign of the return value matters -- no need to have extra checks to ensure the return value always is +/-1 when the actual parameters differ. After removing all the checks, the function body boils down to return age2 - age1; so we can as well replace all invocations with that subtraction. Signed-off-by: Lukas Fleischer --- ui-refs.c | 18 ++ 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/ui-refs.c b/ui-refs.c index 147b665..8a4ce74 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -11,20 +11,6 @@ #include "html.h" #include "ui-shared.h" -static int cmp_age(int age1, int age2) -{ - if (age1 != 0 && age2 != 0) - return age2 - age1; - - if (age1 == 0 && age2 == 0) - return 0; - - if (age1 == 0) - return +1; - - return -1; -} - static int cmp_ref_name(const void *a, const void *b) { struct refinfo *r1 = *(struct refinfo **)a; @@ -38,7 +24,7 @@ static int cmp_branch_age(const void *a, const void *b) struct refinfo *r1 = *(struct refinfo **)a; struct refinfo *r2 = *(struct refinfo **)b; - return cmp_age(r1->commit->committer_date, r2->commit->committer_date); + return r2->commit->committer_date - r1->commit->committer_date; } static int get_ref_age(struct refinfo *ref) @@ -59,7 +45,7 @@ static int cmp_tag_age(const void *a, const void *b) struct refinfo *r1 = *(struct refinfo **)a; struct refinfo *r2 = *(struct refinfo **)b; - return cmp_age(get_ref_age(r1), get_ref_age(r2)); + return get_ref_age(r2)- get_ref_age(r1); } static int print_branch(struct refinfo *ref) -- 1.8.5.3 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 1/4] snapshots: Don't allow sneaked in snapshots requests
On Sat, 01 Feb 2014 at 15:54:22, Sebastian Andrzej Siewior wrote: > On 18.01.14, Sebastian Andrzej Siewior wrote: > > If the snapshots are not enabled then the frontend won't show a link to it. > > The skilled user however may construct the URL on his own and the frontend > > will obey the request. > > This patch adds a check for this case so the requst won't be served. > > Any comments on this one? > While I like this idea [1], I think that Jason is reluctant to add this "fix" [2]. I am putting "fix" in quotes because being able to access "disabled" snapshots is documented since commit 70546a3 (cgitrc.5.txt: Fix documentation of the snapshot mask, 2014-01-13) [3]. > Sebastian > ___ > CGit mailing list > CGit@lists.zx2c4.com > http://lists.zx2c4.com/mailman/listinfo/cgit [1] http://lists.zx2c4.com/pipermail/cgit/2014-January/001692.html [2] http://lists.zx2c4.com/pipermail/cgit/2012-October/000792.html [2] http://git.zx2c4.com/cgit/commit/?id=70546a34583923a73da6fb89c2efb85801294dc1 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 3/4] summary: Add tag head line in the dowload section
On Sun, 19 Jan 2014 at 15:17:02, Jason A. Donenfeld wrote: > On Sat, Jan 18, 2014 at 9:24 PM, Sebastian Andrzej Siewior > wrote: > > If the downloads are disabled one gets only ugly "commit sha1". With > > downloads enabled you see the file name with different extensions a few > > times. > > This patches changes it a little. Instead of printing the hash number it > > prints the first line of the tag i.e. the head line / commit subject if > > available. With downloads enabled it prints additionally the extension > > of the archive type (i.e. .tar, .tar.xz) next to it. > > This is in fact way better than what we have now. I was thinking about > this the other day as well. Perhaps instead of this, we should just > hide the Download column all together, when snapshots are disabled. > > List -- what do you all prefer? Since the column header clearly says "Download", I think it is very confusing to fill it with other information. I also don't see the point in showing arbitrary information just to fill the gap. So +1 to removing the column altogether when snapshots are disabled. The only thing I am not sure about is whether dropping the column breaks the design since we use that 4-column layout throughout the whole summary page. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 2/2] t0111: Additions and fixes
* Rename the capitalize-* filters to dump.* since they also dump the arguments. * Add full argument validation to the email filters. Signed-off-by: Lukas Fleischer --- tests/filters/capitalize-buffer.lua | 17 - tests/filters/capitalize-stdin.sh | 4 tests/filters/dump.lua | 17 + tests/filters/dump.sh | 4 tests/setup.sh | 16 tests/t0111-filter.sh | 4 ++-- 6 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 tests/filters/capitalize-buffer.lua delete mode 100755 tests/filters/capitalize-stdin.sh create mode 100644 tests/filters/dump.lua create mode 100755 tests/filters/dump.sh diff --git a/tests/filters/capitalize-buffer.lua b/tests/filters/capitalize-buffer.lua deleted file mode 100644 index 1f15c93..000 --- a/tests/filters/capitalize-buffer.lua +++ /dev/null @@ -1,17 +0,0 @@ -function filter_open(...) - buffer = "" - for i = 1, select("#", ...) do - buffer = buffer .. select(i, ...) .. " " - end -end - -function filter_close() - html(buffer) - return 0 -end - -function filter_write(str) - buffer = buffer .. string.upper(str) -end - - diff --git a/tests/filters/capitalize-stdin.sh b/tests/filters/capitalize-stdin.sh deleted file mode 100755 index da6f7a1..000 --- a/tests/filters/capitalize-stdin.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -[ "$#" -gt 0 ] && printf "%s " "$*" -tr '[:lower:]' '[:upper:]' diff --git a/tests/filters/dump.lua b/tests/filters/dump.lua new file mode 100644 index 000..1f15c93 --- /dev/null +++ b/tests/filters/dump.lua @@ -0,0 +1,17 @@ +function filter_open(...) + buffer = "" + for i = 1, select("#", ...) do + buffer = buffer .. select(i, ...) .. " " + end +end + +function filter_close() + html(buffer) + return 0 +end + +function filter_write(str) + buffer = buffer .. string.upper(str) +end + + diff --git a/tests/filters/dump.sh b/tests/filters/dump.sh new file mode 100755 index 000..da6f7a1 --- /dev/null +++ b/tests/filters/dump.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +[ "$#" -gt 0 ] && printf "%s " "$*" +tr '[:lower:]' '[:upper:]' diff --git a/tests/setup.sh b/tests/setup.sh index 12c97f5..785edd7 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -128,19 +128,19 @@ repo.desc=spaced repo repo.url=filter-exec repo.path=$PWD/repos/filter/.git repo.desc=filtered repo -repo.about-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh -repo.commit-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh -repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh -repo.source-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh +repo.about-filter=exec:$FILTER_DIRECTORY/dump.sh +repo.commit-filter=exec:$FILTER_DIRECTORY/dump.sh +repo.email-filter=exec:$FILTER_DIRECTORY/dump.sh +repo.source-filter=exec:$FILTER_DIRECTORY/dump.sh repo.readme=master:a+b repo.url=filter-lua repo.path=$PWD/repos/filter/.git repo.desc=filtered repo -repo.about-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua -repo.commit-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua -repo.email-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua -repo.source-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.about-filter=lua:$FILTER_DIRECTORY/dump.lua +repo.commit-filter=lua:$FILTER_DIRECTORY/dump.lua +repo.email-filter=lua:$FILTER_DIRECTORY/dump.lua +repo.source-filter=lua:$FILTER_DIRECTORY/dump.lua repo.readme=master:a+b EOF } diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh index c89020a..730f1c0 100755 --- a/tests/t0111-filter.sh +++ b/tests/t0111-filter.sh @@ -30,11 +30,11 @@ do ' test_expect_success "check whether the $prefix email filter works for authors" ' - grep "A U THOR <aut...@example.com>" tmp + grep " commit A U THOR <aut...@example.com>" tmp ' test_expect_success "check whether the $prefix email filter works for committers" ' - grep "C O MITTER <commit...@example.com>" tmp + grep " commit C O MITTER <commit...@example.com>" tmp ' done -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 1/2] parsing.c: Remove leading space from committer
This did not really break anything in the past since spaces are ignored when rendering HTML. Remove the preceding space anyway to prevent from potential future problems. Signed-off-by: Lukas Fleischer --- This would get fixed anyway when switching to strip_prefix(). However, it is better to do this now to avoid any problems. It is also "required" for the following patch (otherwise, we would have to add a workaround for this bug to the test case which doesn't seem right and might lead to confusion when the bug suddenly disappears after the strip_prefix() migrate and the tests break). parsing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsing.c b/parsing.c index 0062550..599f61e 100644 --- a/parsing.c +++ b/parsing.c @@ -156,7 +156,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) } if (p && !prefixcmp(p, "committer ")) { - p = parse_user(p + 9, &ret->committer, &ret->committer_email, + p = parse_user(p + 10, &ret->committer, &ret->committer_email, &ret->committer_date); } -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 4/4] Remove callback data parameter for cache slots
This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer --- cache.c | 14 ++ cache.h | 5 ++--- cgit.c | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cache.c b/cache.c index fa83ddc..fcd461f 100644 --- a/cache.c +++ b/cache.c @@ -24,7 +24,6 @@ struct cache_slot { int keylen; int ttl; cache_fill_fn fn; - void *cbdata; int cache_fd; int lock_fd; const char *cache_name; @@ -187,7 +186,7 @@ static int fill_slot(struct cache_slot *slot) return errno; /* Generate cache content */ - slot->fn(slot->cbdata); + slot->fn(); /* Restore stdout */ if (dup2(tmp, STDOUT_FILENO) == -1) @@ -277,7 +276,7 @@ static int process_slot(struct cache_slot *slot) if ((err = lock_slot(slot)) != 0) { cache_log("[cgit] Unable to lock slot %s: %s (%d)\n", slot->lock_name, strerror(err), err); - slot->fn(slot->cbdata); + slot->fn(); return 0; } @@ -286,7 +285,7 @@ static int process_slot(struct cache_slot *slot) slot->lock_name, strerror(err), err); unlock_slot(slot, 0); close_lock(slot); - slot->fn(slot->cbdata); + slot->fn(); return 0; } // We've got a valid cache slot in the lock file, which @@ -310,7 +309,7 @@ static int process_slot(struct cache_slot *slot) /* Print cached content to stdout, generate the content if necessary. */ int cache_process(int size, const char *path, const char *key, int ttl, - cache_fill_fn fn, void *cbdata) + cache_fill_fn fn) { unsigned long hash; int i; @@ -321,14 +320,14 @@ int cache_process(int size, const char *path, const char *key, int ttl, /* If the cache is disabled, just generate the content */ if (size <= 0) { - fn(cbdata); + fn(); return 0; } /* Verify input, calculate filenames */ if (!path) { cache_log("[cgit] Cache path not specified, caching is disabled\n"); - fn(cbdata); + fn(); return 0; } if (!key) @@ -343,7 +342,6 @@ int cache_process(int size, const char *path, const char *key, int ttl, strbuf_addbuf(&lockname, &filename); strbuf_addstr(&lockname, ".lock"); slot.fn = fn; - slot.cbdata = cbdata; slot.ttl = ttl; slot.cache_name = filename.buf; slot.lock_name = lockname.buf; diff --git a/cache.h b/cache.h index 5cfdb4f..9392836 100644 --- a/cache.h +++ b/cache.h @@ -6,7 +6,7 @@ #ifndef CGIT_CACHE_H #define CGIT_CACHE_H -typedef void (*cache_fill_fn)(void *cbdata); +typedef void (*cache_fill_fn)(void); /* Print cached content to stdout, generate the content if necessary. @@ -17,13 +17,12 @@ typedef void (*cache_fill_fn)(void *cbdata); * key the key used to lookup cache files * ttl max cache time in seconds for this key * fn content generator function for this key - * cbdata user-supplied data to the content generator function * * Return value * 0 indicates success, everyting else is an error */ extern int cache_process(int size, const char *path, const char *key, int ttl, -cache_fill_fn fn, void *cbdata); +cache_fill_fn fn); /* List info about all cache entries on stdout */ diff --git a/cgit.c b/cgit.c index 19bcd0d..9ea4099 100644 --- a/cgit.c +++ b/cgit.c @@ -593,7 +593,7 @@ static int prepare_repo_cmd(void) return 0; } -static void process_request(void *cbdata) +static void process_request(void) { struct cgit_cmd *cmd; @@ -957,7 +957,7 @@ int main(int argc, const char **argv) if (ctx.cfg.nocache) ctx.cfg.cache_size = 0; err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root, - ctx.qry.raw, ttl, process_request, NULL); + ctx.qry.raw, ttl, process_request); cgit_cleanup_filters(); if (err) cgit_print_error("Error processing page: %s (%d)", -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 3/4] cgit.c: Remove context parameter from initializations
In initialization routines, use the global context variable instead of passing a pointer around locally. Signed-off-by: Lukas Fleischer --- cgit.c | 207 - 1 file changed, 103 insertions(+), 104 deletions(-) diff --git a/cgit.c b/cgit.c index 54efd59..19bcd0d 100644 --- a/cgit.c +++ b/cgit.c @@ -320,78 +320,78 @@ static void querystring_cb(const char *name, const char *value) } } -static void prepare_context(struct cgit_context *ctx) +static void prepare_context(void) { - memset(ctx, 0, sizeof(*ctx)); - ctx->cfg.agefile = "info/web/last-modified"; - ctx->cfg.nocache = 0; - ctx->cfg.cache_size = 0; - ctx->cfg.cache_max_create_time = 5; - ctx->cfg.cache_root = CGIT_CACHE_ROOT; - ctx->cfg.cache_about_ttl = 15; - ctx->cfg.cache_repo_ttl = 5; - ctx->cfg.cache_root_ttl = 5; - ctx->cfg.cache_scanrc_ttl = 15; - ctx->cfg.cache_dynamic_ttl = 5; - ctx->cfg.cache_static_ttl = -1; - ctx->cfg.case_sensitive_sort = 1; - ctx->cfg.branch_sort = 0; - ctx->cfg.commit_sort = 0; - ctx->cfg.css = "/cgit.css"; - ctx->cfg.logo = "/cgit.png"; - ctx->cfg.favicon = "/favicon.ico"; - ctx->cfg.local_time = 0; - ctx->cfg.enable_http_clone = 1; - ctx->cfg.enable_index_owner = 1; - ctx->cfg.enable_tree_linenumbers = 1; - ctx->cfg.enable_git_config = 0; - ctx->cfg.max_repo_count = 50; - ctx->cfg.max_commit_count = 50; - ctx->cfg.max_lock_attempts = 5; - ctx->cfg.max_msg_len = 80; - ctx->cfg.max_repodesc_len = 80; - ctx->cfg.max_blob_size = 0; - ctx->cfg.max_stats = 0; - ctx->cfg.project_list = NULL; - ctx->cfg.renamelimit = -1; - ctx->cfg.remove_suffix = 0; - ctx->cfg.robots = "index, nofollow"; - ctx->cfg.root_title = "Git repository browser"; - ctx->cfg.root_desc = "a fast webinterface for the git dscm"; - ctx->cfg.scan_hidden_path = 0; - ctx->cfg.script_name = CGIT_SCRIPT_NAME; - ctx->cfg.section = ""; - ctx->cfg.repository_sort = "name"; - ctx->cfg.section_sort = 1; - ctx->cfg.summary_branches = 10; - ctx->cfg.summary_log = 10; - ctx->cfg.summary_tags = 10; - ctx->cfg.max_atom_items = 10; - ctx->cfg.ssdiff = 0; - ctx->env.cgit_config = getenv("CGIT_CONFIG"); - ctx->env.http_host = getenv("HTTP_HOST"); - ctx->env.https = getenv("HTTPS"); - ctx->env.no_http = getenv("NO_HTTP"); - ctx->env.path_info = getenv("PATH_INFO"); - ctx->env.query_string = getenv("QUERY_STRING"); - ctx->env.request_method = getenv("REQUEST_METHOD"); - ctx->env.script_name = getenv("SCRIPT_NAME"); - ctx->env.server_name = getenv("SERVER_NAME"); - ctx->env.server_port = getenv("SERVER_PORT"); - ctx->page.mimetype = "text/html"; - ctx->page.charset = PAGE_ENCODING; - ctx->page.filename = NULL; - ctx->page.size = 0; - ctx->page.modified = time(NULL); - ctx->page.expires = ctx->page.modified; - ctx->page.etag = NULL; - memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list)); - if (ctx->env.script_name) - ctx->cfg.script_name = xstrdup(ctx->env.script_name); - if (ctx->env.query_string) - ctx->qry.raw = xstrdup(ctx->env.query_string); - if (!ctx->env.cgit_config) - ctx->env.cgit_config = CGIT_CONFIG; + memset(&ctx, 0, sizeof(ctx)); + ctx.cfg.agefile = "info/web/last-modified"; + ctx.cfg.nocache = 0; + ctx.cfg.cache_size = 0; + ctx.cfg.cache_max_create_time = 5; + ctx.cfg.cache_root = CGIT_CACHE_ROOT; + ctx.cfg.cache_about_ttl = 15; + ctx.cfg.cache_repo_ttl = 5; + ctx.cfg.cache_root_ttl = 5; + ctx.cfg.cache_scanrc_ttl = 15; + ctx.cfg.cache_dynamic_ttl = 5; + ctx.cfg.cache_static_ttl = -1; + ctx.cfg.case_sensitive_sort = 1; + ctx.cfg.branch_sort = 0; + ctx.cfg.commit_sort = 0; + ctx.cfg.css = "/cgit.css"; + ctx.cfg.logo = "/cgit.png"; + ctx.cfg.favicon = "/favicon.ico"; + ctx.cfg.local_time = 0; + ctx.cfg.enable_http_clone = 1; + ctx.cfg.enable_index_owner = 1; + ctx.cfg.enable_tree_linenumbers = 1; + ctx.cfg.enable_git_config = 0; + ctx.cfg.max_repo_count = 50; + ctx.cfg.max_commit_count = 50; + ctx.cfg.max_lock_attempts = 5; + ctx.c
[PATCH 0/4] Remove references to the global context variable
Jason noticed that sometimes, we pass a reference (pointer) to the global context variable. This series removes all such references and replaces them with direct use of the global variable. Most of the patches are much easier to review with the following options: --word-diff=color --word-diff-regex='[a-zA-Z_]+|->|\.' Comments welcome! Lukas Fleischer (4): Remove context parameter from cgit_print_*() Remove context parameter from all commands cgit.c: Remove context parameter from initializations Remove callback data parameter for cache slots cache.c | 14 ++- cache.h | 5 +- cgit.c| 249 cmd.c | 102 ++-- cmd.h | 4 +- ui-atom.c | 2 +- ui-blob.c | 2 +- ui-clone.c| 48 +- ui-clone.h| 6 +- ui-diff.c | 2 +- ui-patch.c| 2 +- ui-plain.c| 14 +-- ui-plain.h| 2 +- ui-repolist.c | 6 +- ui-shared.c | 297 +- ui-shared.h | 6 +- ui-snapshot.c | 8 +- ui-stats.c| 29 +++--- ui-stats.h| 2 +- 19 files changed, 397 insertions(+), 403 deletions(-) -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 2/4] Remove context parameter from all commands
Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() Fix all invocations of these functions accordingly. Signed-off-by: Lukas Fleischer --- cgit.c | 4 +-- cmd.c | 100 ++--- cmd.h | 4 +-- ui-clone.c | 42 +- ui-clone.h | 6 ++-- ui-plain.c | 10 +++ ui-plain.h | 2 +- ui-stats.c | 29 +- ui-stats.h | 2 +- 9 files changed, 99 insertions(+), 100 deletions(-) diff --git a/cgit.c b/cgit.c index 512ef56..54efd59 100644 --- a/cgit.c +++ b/cgit.c @@ -598,7 +598,7 @@ static void process_request(void *cbdata) struct cgit_context *ctx = cbdata; struct cgit_cmd *cmd; - cmd = cgit_get_cmd(ctx); + cmd = cgit_get_cmd(); if (!cmd) { ctx->page.title = "cgit error"; ctx->page.status = 404; @@ -640,7 +640,7 @@ static void process_request(void *cbdata) cgit_print_pageheader(); } - cmd->fn(ctx); + cmd->fn(); if (cmd->want_layout) cgit_print_docend(); diff --git a/cmd.c b/cmd.c index 3022452..cbd235c 100644 --- a/cmd.c +++ b/cmd.c @@ -26,120 +26,120 @@ #include "ui-tag.h" #include "ui-tree.h" -static void HEAD_fn(struct cgit_context *ctx) +static void HEAD_fn(void) { - cgit_clone_head(ctx); + cgit_clone_head(); } -static void atom_fn(struct cgit_context *ctx) +static void atom_fn(void) { - cgit_print_atom(ctx->qry.head, ctx->qry.path, ctx->cfg.max_atom_items); + cgit_print_atom(ctx.qry.head, ctx.qry.path, ctx.cfg.max_atom_items); } -static void about_fn(struct cgit_context *ctx) +static void about_fn(void) { - if (ctx->repo) - cgit_print_repo_readme(ctx->qry.path); + if (ctx.repo) + cgit_print_repo_readme(ctx.qry.path); else cgit_print_site_readme(); } -static void blob_fn(struct cgit_context *ctx) +static void blob_fn(void) { - cgit_print_blob(ctx->qry.sha1, ctx->qry.path, ctx->qry.head, 0); + cgit_print_blob(ctx.qry.sha1, ctx.qry.path, ctx.qry.head, 0); } -static void commit_fn(struct cgit_context *ctx) +static void commit_fn(void) { - cgit_print_commit(ctx->qry.sha1, ctx->qry.path); + cgit_print_commit(ctx.qry.sha1, ctx.qry.path); } -static void diff_fn(struct cgit_context *ctx) +static void diff_fn(void) { - cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1, 0); + cgit_print_diff(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1, 0); } -static void rawdiff_fn(struct cgit_context *ctx) +static void rawdiff_fn(void) { - cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1, 1); + cgit_print_diff(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1, 1); } -static void info_fn(struct cgit_context *ctx) +static void info_fn(void) { - cgit_clone_info(ctx); + cgit_clone_info(); } -static void log_fn(struct cgit_context *ctx) +static void log_fn(void) { - cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count, - ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1, - ctx->repo->enable_commit_graph, - ctx->repo->commit_sort); + cgit_print_log(ctx.qry.sha1, ctx.qry.ofs, ctx.cfg.max_commit_count, + ctx.qry.grep, ctx.qry.search, ctx.qry.path, 1, + ctx.repo->enable_commit_graph, + ctx.repo->commit_sort); } -static void ls_cache_fn(struct cgit_context *ctx) +static void ls_cache_fn(void) { - ctx->page.mimetype = "text/plain"; - ctx->page.filename = "ls-cache.txt"; + ctx.page.mimetype = "text/plain"; + ctx.page.filename = "ls-cache.txt"; cgit_print_http_headers(); - cache_ls(ctx->cfg.cache_root); + cache_ls(ctx.cfg.cache_root); } -static void objects_fn(struct cgit_context *ctx) +static void objects_fn(void) { - cgit_clone_objects(ctx); + cgit_clone_objects(); } -static void repolist_fn(struct cgit_context *ctx) +static void repolist_fn(void) { cgit_print_repolist(); } -static void patch_fn(struct cgit_context *ctx) +static void patch_fn(void) { - cgit_print_patch(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path); + cgit_print_patch(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path); } -static void plain_fn(struct cgit_context *ctx) +static void plain_fn(void) { - cgit_print_plain(ctx); + cgit_print_plain(); } -s
[PATCH 3/3] t0111: Check all arguments
In the filter checks, check whether all arguments are passed properly instead of validating the buffer/stdin only. Signed-off-by: Lukas Fleischer --- tests/filters/capitalize-buffer.lua | 3 +++ tests/filters/capitalize-stdin.sh | 1 + tests/t0111-filter.sh | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/filters/capitalize-buffer.lua b/tests/filters/capitalize-buffer.lua index 7ca4ec6..1f15c93 100644 --- a/tests/filters/capitalize-buffer.lua +++ b/tests/filters/capitalize-buffer.lua @@ -1,5 +1,8 @@ function filter_open(...) buffer = "" + for i = 1, select("#", ...) do + buffer = buffer .. select(i, ...) .. " " + end end function filter_close() diff --git a/tests/filters/capitalize-stdin.sh b/tests/filters/capitalize-stdin.sh index c9f4719..da6f7a1 100755 --- a/tests/filters/capitalize-stdin.sh +++ b/tests/filters/capitalize-stdin.sh @@ -1,3 +1,4 @@ #!/bin/sh +[ "$#" -gt 0 ] && printf "%s " "$*" tr '[:lower:]' '[:upper:]' diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh index dab6aa8..c89020a 100755 --- a/tests/t0111-filter.sh +++ b/tests/t0111-filter.sh @@ -10,7 +10,7 @@ do " test_expect_success "check whether the $prefix source filter works" ' - grep "HELLO$" tmp + grep "a+b HELLO$" tmp ' test_expect_success "generate filter-$prefix/about/" " @@ -18,7 +18,7 @@ do " test_expect_success "check whether the $prefix about filter works" ' - grep "HELLO$" tmp + grep "a+b HELLO$" tmp ' test_expect_success "generate filter-$prefix/commit/" " -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH v2 2/3] t0111: Add basic tests for Lua filters
Signed-off-by: Lukas Fleischer --- tests/filters/capitalize-buffer.lua | 14 tests/setup.sh | 9 + tests/t0111-filter.sh | 65 +++-- 3 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 tests/filters/capitalize-buffer.lua diff --git a/tests/filters/capitalize-buffer.lua b/tests/filters/capitalize-buffer.lua new file mode 100644 index 000..7ca4ec6 --- /dev/null +++ b/tests/filters/capitalize-buffer.lua @@ -0,0 +1,14 @@ +function filter_open(...) + buffer = "" +end + +function filter_close() + html(buffer) + return 0 +end + +function filter_write(str) + buffer = buffer .. string.upper(str) +end + + diff --git a/tests/setup.sh b/tests/setup.sh index a0a9be2..12c97f5 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -133,6 +133,15 @@ repo.commit-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh repo.source-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh repo.readme=master:a+b + +repo.url=filter-lua +repo.path=$PWD/repos/filter/.git +repo.desc=filtered repo +repo.about-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.commit-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.email-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.source-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.readme=master:a+b EOF } diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh index c235652..dab6aa8 100755 --- a/tests/t0111-filter.sh +++ b/tests/t0111-filter.sh @@ -3,36 +3,39 @@ test_description='Check filtered content' . ./setup.sh -test_expect_success 'generate filter-exec/tree/a%2bb' ' - cgit_url "filter-exec/tree/a%2bb" >tmp -' - -test_expect_success 'check whether the exec source filter works' ' - grep "HELLO$" tmp -' - -test_expect_success 'generate filter-exec/about/' ' - cgit_url "filter-exec/about/" >tmp -' - -test_expect_success 'check whether the exec about filter works' ' - grep "HELLO$" tmp -' - -test_expect_success 'generate filter-exec/commit/' ' - cgit_url "filter-exec/commit/" >tmp -' - -test_expect_success 'check whether the exec commit filter works' ' - grep "ADD A+B" tmp -' - -test_expect_success 'check whether the exec email filter works for authors' ' - grep "A U THOR <aut...@example.com>" tmp -' - -test_expect_success 'check whether the exec email filter works for committers' ' - grep "C O MITTER <commit...@example.com>" tmp -' +for prefix in exec lua +do + test_expect_success "generate filter-$prefix/tree/a%2bb" " + cgit_url 'filter-$prefix/tree/a%2bb' >tmp + " + + test_expect_success "check whether the $prefix source filter works" ' + grep "HELLO$" tmp + ' + + test_expect_success "generate filter-$prefix/about/" " + cgit_url 'filter-$prefix/about/' >tmp + " + + test_expect_success "check whether the $prefix about filter works" ' + grep "HELLO$" tmp + ' + + test_expect_success "generate filter-$prefix/commit/" " + cgit_url 'filter-$prefix/commit/' >tmp + " + + test_expect_success "check whether the $prefix commit filter works" ' + grep "ADD A+B" tmp + ' + + test_expect_success "check whether the $prefix email filter works for authors" ' + grep "A U THOR <aut...@example.com>" tmp + ' + + test_expect_success "check whether the $prefix email filter works for committers" ' + grep "C O MITTER <commit...@example.com>" tmp + ' +done test_done -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH v2 1/3] t0111: Prepare for other filter prefixes
* Validate the email filter by manipulating stdin. Additional checks for all the arguments can be added in a later patch. * Add the exec prefix to all informational messages. * Rename the filter repository to filter-exec. The Git repository itself is not renamed since it can be shared amongst all filter types. Signed-off-by: Lukas Fleischer --- tests/filters/capitalize-argv1.sh | 3 --- tests/setup.sh| 4 ++-- tests/t0111-filter.sh | 26 +- 3 files changed, 15 insertions(+), 18 deletions(-) delete mode 100755 tests/filters/capitalize-argv1.sh diff --git a/tests/filters/capitalize-argv1.sh b/tests/filters/capitalize-argv1.sh deleted file mode 100755 index 2ea0098..000 --- a/tests/filters/capitalize-argv1.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "$1" | tr '[:lower:]' '[:upper:]' diff --git a/tests/setup.sh b/tests/setup.sh index 861f48a..a0a9be2 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -125,12 +125,12 @@ repo.url=with space repo.path=$PWD/repos/with space/.git repo.desc=spaced repo -repo.url=filter +repo.url=filter-exec repo.path=$PWD/repos/filter/.git repo.desc=filtered repo repo.about-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh repo.commit-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh -repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-argv1.sh +repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh repo.source-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh repo.readme=master:a+b EOF diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh index 2f99880..c235652 100755 --- a/tests/t0111-filter.sh +++ b/tests/t0111-filter.sh @@ -3,36 +3,36 @@ test_description='Check filtered content' . ./setup.sh -test_expect_success 'generate filter/tree/a%2bb' ' - cgit_url "filter/tree/a%2bb" >tmp +test_expect_success 'generate filter-exec/tree/a%2bb' ' + cgit_url "filter-exec/tree/a%2bb" >tmp ' -test_expect_success 'check whether the source filter works' ' +test_expect_success 'check whether the exec source filter works' ' grep "HELLO$" tmp ' -test_expect_success 'generate filter/about/' ' - cgit_url "filter/about/" >tmp +test_expect_success 'generate filter-exec/about/' ' + cgit_url "filter-exec/about/" >tmp ' -test_expect_success 'check whether the about filter works' ' +test_expect_success 'check whether the exec about filter works' ' grep "HELLO$" tmp ' -test_expect_success 'generate filter/commit/' ' - cgit_url "filter/commit/" >tmp +test_expect_success 'generate filter-exec/commit/' ' + cgit_url "filter-exec/commit/" >tmp ' -test_expect_success 'check whether the commit filter works' ' +test_expect_success 'check whether the exec commit filter works' ' grep "ADD A+B" tmp ' -test_expect_success 'check whether the email filter works for authors' ' - grep "" tmp +test_expect_success 'check whether the exec email filter works for authors' ' + grep "A U THOR <aut...@example.com>" tmp ' -test_expect_success 'check whether the email filter works for committers' ' - grep "" tmp +test_expect_success 'check whether the exec email filter works for committers' ' + grep "C O MITTER <commit...@example.com>" tmp ' test_done -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 1/2] t0111: Prepare for other filter prefixes
Rename the filter repository to filter-exec. The Git repository itself is not renamed since it can be shared amongst all filter types. Signed-off-by: Lukas Fleischer --- tests/setup.sh| 2 +- tests/t0111-filter.sh | 22 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/setup.sh b/tests/setup.sh index 861f48a..6499836 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -125,7 +125,7 @@ repo.url=with space repo.path=$PWD/repos/with space/.git repo.desc=spaced repo -repo.url=filter +repo.url=filter-exec repo.path=$PWD/repos/filter/.git repo.desc=filtered repo repo.about-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh index 2f99880..c7e9d05 100755 --- a/tests/t0111-filter.sh +++ b/tests/t0111-filter.sh @@ -3,35 +3,35 @@ test_description='Check filtered content' . ./setup.sh -test_expect_success 'generate filter/tree/a%2bb' ' - cgit_url "filter/tree/a%2bb" >tmp +test_expect_success 'generate filter-exec/tree/a%2bb' ' + cgit_url "filter-exec/tree/a%2bb" >tmp ' -test_expect_success 'check whether the source filter works' ' +test_expect_success 'check whether the exec source filter works' ' grep "HELLO$" tmp ' -test_expect_success 'generate filter/about/' ' - cgit_url "filter/about/" >tmp +test_expect_success 'generate filter-exec/about/' ' + cgit_url "filter-exec/about/" >tmp ' -test_expect_success 'check whether the about filter works' ' +test_expect_success 'check whether the exec about filter works' ' grep "HELLO$" tmp ' -test_expect_success 'generate filter/commit/' ' - cgit_url "filter/commit/" >tmp +test_expect_success 'generate filter-exec/commit/' ' + cgit_url "filter-exec/commit/" >tmp ' -test_expect_success 'check whether the commit filter works' ' +test_expect_success 'check whether the exec commit filter works' ' grep "ADD A+B" tmp ' -test_expect_success 'check whether the email filter works for authors' ' +test_expect_success 'check whether the exec email filter works for authors' ' grep "" tmp ' -test_expect_success 'check whether the email filter works for committers' ' +test_expect_success 'check whether the exec email filter works for committers' ' grep "" tmp ' -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 2/2] t0111: Add basic tests for Lua filters
Signed-off-by: Lukas Fleischer --- tests/filters/capitalize-buffer.lua | 14 ++ tests/setup.sh | 9 + tests/t0111-filter.sh | 32 3 files changed, 55 insertions(+) create mode 100644 tests/filters/capitalize-buffer.lua diff --git a/tests/filters/capitalize-buffer.lua b/tests/filters/capitalize-buffer.lua new file mode 100644 index 000..7ca4ec6 --- /dev/null +++ b/tests/filters/capitalize-buffer.lua @@ -0,0 +1,14 @@ +function filter_open(...) + buffer = "" +end + +function filter_close() + html(buffer) + return 0 +end + +function filter_write(str) + buffer = buffer .. string.upper(str) +end + + diff --git a/tests/setup.sh b/tests/setup.sh index 6499836..529f410 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -133,6 +133,15 @@ repo.commit-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-argv1.sh repo.source-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh repo.readme=master:a+b + +repo.url=filter-lua +repo.path=$PWD/repos/filter/.git +repo.desc=filtered repo +repo.about-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.commit-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.email-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.source-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua +repo.readme=master:a+b EOF } diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh index c7e9d05..3833de4 100755 --- a/tests/t0111-filter.sh +++ b/tests/t0111-filter.sh @@ -35,4 +35,36 @@ test_expect_success 'check whether the exec email filter works for committers' ' grep "" tmp ' +test_expect_success 'generate filter-lua/tree/a%2bb' ' + cgit_url "filter-lua/tree/a%2bb" >tmp +' + +test_expect_success 'check whether the Lua source filter works' ' + grep "HELLO$" tmp +' + +test_expect_success 'generate filter-lua/about/' ' + cgit_url "filter-lua/about/" >tmp +' + +test_expect_success 'check whether the Lua about filter works' ' + grep "HELLO$" tmp +' + +test_expect_success 'generate filter-lua/commit/' ' + cgit_url "filter-lua/commit/" >tmp +' + +test_expect_success 'check whether the Lua commit filter works' ' + grep "ADD A+B" tmp +' + +test_expect_success 'check whether the Lua email filter works for authors' ' + grep "A U THOR <aut...@example.com>" tmp +' + +test_expect_success 'check whether the Lua email filter works for committers' ' + grep "C O MITTER <commit...@example.com>" tmp +' + test_done -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH/RFC] tests/: Add t0111-filter.sh
This adds basic tests for all types of exec filters. Signed-off-by: Lukas Fleischer --- This only includes tests for exec filters so far. I will send another patch for Lua filters once this one is merged. tests/filters/capitalize-argv1.sh | 3 +++ tests/filters/capitalize-stdin.sh | 3 +++ tests/setup.sh| 13 + tests/t0111-filter.sh | 38 ++ 4 files changed, 57 insertions(+) create mode 100755 tests/filters/capitalize-argv1.sh create mode 100755 tests/filters/capitalize-stdin.sh create mode 100755 tests/t0111-filter.sh diff --git a/tests/filters/capitalize-argv1.sh b/tests/filters/capitalize-argv1.sh new file mode 100755 index 000..2ea0098 --- /dev/null +++ b/tests/filters/capitalize-argv1.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "$1" | tr '[:lower:]' '[:upper:]' diff --git a/tests/filters/capitalize-stdin.sh b/tests/filters/capitalize-stdin.sh new file mode 100755 index 000..c9f4719 --- /dev/null +++ b/tests/filters/capitalize-stdin.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +tr '[:lower:]' '[:upper:]' diff --git a/tests/setup.sh b/tests/setup.sh index 5476ced..861f48a 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -58,6 +58,8 @@ else PATH="$(pwd)/../..:$PATH" fi +FILTER_DIRECTORY=$(cd ../filters && pwd) + mkrepo() { name=$1 count=$2 @@ -90,6 +92,7 @@ setup_repos() mkrepo repos/bar 50 >/dev/null mkrepo repos/foo+bar 10 testplus >/dev/null mkrepo "repos/with space" 2 >/dev/null + mkrepo repos/filter 5 testplus >/dev/null cat >cgitrc <tmp +' + +test_expect_success 'check whether the source filter works' ' + grep "HELLO$" tmp +' + +test_expect_success 'generate filter/about/' ' + cgit_url "filter/about/" >tmp +' + +test_expect_success 'check whether the about filter works' ' + grep "HELLO$" tmp +' + +test_expect_success 'generate filter/commit/' ' + cgit_url "filter/commit/" >tmp +' + +test_expect_success 'check whether the commit filter works' ' + grep "ADD A+B" tmp +' + +test_expect_success 'check whether the email filter works for authors' ' + grep "" tmp +' + +test_expect_success 'check whether the email filter works for committers' ' + grep "" tmp +' + +test_done -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] cgitrc.5.txt: Fix documentation of the snapshot mask
Mention that the snapshot setting only specifies the formats that links are generated for and not the set of formats that are accessible via HTTP. Signed-off-by: Lukas Fleischer --- cgitrc.5.txt | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 52caed0..7e9eaeb 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -382,10 +382,10 @@ side-by-side-diffs:: default. Default value: "0". snapshots:: - Text which specifies the default set of snapshot formats generated by - cgit. The value is a space-separated list of zero or more of the - values "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip". Default value: - none. + Text which specifies the default set of snapshot formats that cgit + generates links for. The value is a space-separated list of zero or + more of the values "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip". + Default value: none. source-filter:: Specifies a command which will be invoked to format plaintext blobs @@ -526,8 +526,9 @@ repo.readme:: file. Default value: . repo.snapshots:: - A mask of allowed snapshot-formats for this repo, restricted by the - "snapshots" global setting. Default value: . + A mask of snapshot formats for this repo that cgit generates links for, + restricted by the global "snapshots" setting. Default value: + . repo.section:: Override the current section name for this repository. Default value: -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 06/12] filter: add preliminary lua support
On Mon, 13 Jan 2014 at 05:11:13, Jason A. Donenfeld wrote: > Signed-off-by: Jason A. Donenfeld > --- > cgit.h | 2 +- > cgit.mk | 13 ++- > filter.c | 284 > --- > 3 files changed, 230 insertions(+), 69 deletions(-) > > [...] > +static ssize_t write_lua_filter(struct cgit_filter *base, const void *buf, > size_t count) > +{ > + struct lua_filter *filter = (struct lua_filter *) base; > + > + lua_getglobal(filter->lua_state, "filter_write"); > + lua_pushlstring(filter->lua_state, buf, count); > + if (lua_pcall(filter->lua_state, 1, 0, 0)) { > + errno = EPROTO; Just noticed that this also breaks compilation under OpenBSD: ../filter.c:199: error: 'EPROTO' undeclared (first use in this function) The error number seems to be part of POSIX, though, so not sure if we should care about OpenBSD being non-compliant here. > + return -1; > + } > + return count; > +} > [...] ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 06/12] filter: add preliminary lua support
This patch is quite messy and hard to read. I read your cover-letter but maybe you still want to clean this up when dealing with the other suggestions during a rebase -- shouldn't be too hard when using an editor with good Git integration (like fugitive for Vim). On Mon, 13 Jan 2014 at 05:11:13, Jason A. Donenfeld wrote: > [...] > +ifdef NO_LUA We should document this in the installation instructions section in the README. I also wonder whether this should made an opt-in feature? > + CFLAGS += -DNO_LUA > +else > + CGIT_LIBS += -llua Similar: Add Lua/LuaJIT (Will you squash the LuaJIT Makefile fix into this one? Or is there any reason to use Lua first and switch to LuaJIT later?) to the dependencies section of the README file and mention that it is optional. > +endif > + > +CGIT_LIBS += -ldl > + > + > + > CGIT_OBJ_NAMES += cgit.o > CGIT_OBJ_NAMES += cache.o > CGIT_OBJ_NAMES += cmd.o > [...] ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH 05/12] filter: basic write hooking infrastructure
On Mon, 13 Jan 2014 at 05:11:12, Jason A. Donenfeld wrote: > Filters can now call hook_write and unhook_write if they want to > redirect writing to stdout to a different function. This saves us from > potential file descriptor pipes and other less efficient mechanisms. > > We do this instead of replacing the call in html_raw because some places > stdlib's printf functions are used (ui-patch or within git itself), > which has its own internal buffering, which makes it difficult to > interlace our function calls. So, we dlsym libc's write and then > override it in the link stage. Clever. Not sure whether I like it, though. I think it would be much better to have a more transparent hooking mechanism that does use any "tricks". Could you elaborate on where Git directly prints for us? > > Signed-off-by: Jason A. Donenfeld > --- > cgit.c | 2 ++ > cgit.h | 1 + > cgit.mk | 4 +++- > filter.c | 30 ++ > 4 files changed, 36 insertions(+), 1 deletion(-) > > [...] > diff --git a/cgit.mk b/cgit.mk > index 19a76e7..9d6dea8 100644 > --- a/cgit.mk > +++ b/cgit.mk > @@ -61,6 +61,8 @@ $(CGIT_VERSION_OBJS): $(CGIT_PREFIX)VERSION > $(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = \ > -DCGIT_VERSION='"$(CGIT_VERSION)"' > > +CGIT_LIBS += -ldl This breaks compilation at least on FreeBSD and OpenBSD which do no have libdl (and have dlsym() built-in as a part of libc). I am not sure about other platforms. So if we go this way, we should check how to make this cross-platform compatible. > + Stray newline? > > # Git handles dependencies using ":=" so dependencies in CGIT_OBJ are not > # handled by that and we must handle them ourselves. > @@ -88,4 +90,4 @@ $(CGIT_OBJS): %.o: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS > $(missing_dep_dirs) > $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) > $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $< > > $(CGIT_PREFIX)cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS) > - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter > %.o,$^) $(LIBS) > + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter > %.o,$^) $(LIBS) $(CGIT_LIBS) > diff --git a/filter.c b/filter.c > index 86c1d5d..8990575 100644 > --- a/filter.c > +++ b/filter.c > @@ -12,6 +12,10 @@ > #include > #include > #include > +#include > + > +static ssize_t (*libc_write)(int fd, const void *buf, size_t count); > +static ssize_t (*filter_write)(const void *buf, size_t count) = NULL; > > static int open_exec_filter(struct cgit_filter *base, va_list ap) > { > @@ -192,3 +196,29 @@ void cgit_cleanup_filters(void) > reap_filter(cgit_repolist.repos[i].source_filter); > } > } > + > +void cgit_init_filters(void) > +{ > + libc_write = dlsym(RTLD_NEXT, "write"); > + if (!libc_write) > + die("Could not locate libc's write function"); > +} > + > +ssize_t write(int fd, const void *buf, size_t count) > +{ > + if (fd != STDOUT_FILENO || !filter_write) > + return libc_write(fd, buf, count); > + return filter_write(buf, count); > +} > + > +static inline void hook_write(ssize_t (*new_write)(const void *buf, size_t > count)) > +{ > + /* We want to avoid buggy nested patterns. */ > + assert(filter_write == NULL); > + filter_write = new_write; > +} > +static inline void unhook_write() > +{ > + assert(filter_write != NULL); > + filter_write = NULL; > +} > -- > 1.8.5.2 > > ___ > CGit mailing list > CGit@lists.zx2c4.com > http://lists.zx2c4.com/mailman/listinfo/cgit ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Disallow downloading disabled snapshot formats
On Fri, 10 Jan 2014 at 17:11:46, Jason A. Donenfeld wrote: > On Fri, Jan 10, 2014 at 3:38 PM, Lukas Fleischer wrote: > > We did only display enabled snapshot formats but we did not prevent from > > downloading disabled formats when requested. Fix this by adding an > > appropriate check. > > Previously: > http://lists.zx2c4.com/pipermail/cgit/2012-June/000641.html > http://lists.zx2c4.com/pipermail/cgit/2012-October/000792.html I was also thinking of server load. If we want to leave it as-is, we should fix the documentation which currently says: repo.snapshots:: A mask of allowed snapshot-formats for this repo, restricted by the "snapshots" global setting. Default value: . There should at least be a note stating that "allowed" only means "linked" here. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: [PATCH] Disallow downloading disabled snapshot formats
On Fri, 10 Jan 2014 at 15:50:14, John Keeping wrote: > On Fri, Jan 10, 2014 at 03:38:06PM +0100, Lukas Fleischer wrote: > [...] > > +test_expect_success 'try to download a disabled snapshot format' ' > > + cgit_url "foo/snapshot/master.tar.xz" | > > + grep "Unsupported snapshot format" > > I really dislike seeing pipes in the test suite. Can we redirect to > file instead and then grep the file? This helps ensure that the exit > code from CGit is correct (I don't know if we expect it to be zero or > non-zero here, but if the latter then at least test_must_fail checks > that the process didn't segfault - I suspect it should be zero though). Does this matter here at all? If cgit_url fails in any (unpredictable) way, e.g. segfaults, it probably won't print the string "Unsupported snapshot format" and the whole test case will fail. The Git test suite itself also uses grep(1) with a pipe several times. I agree that we shouldn't use pipes when inverting the result (looking for non-existent patterns), though. > > > +' > > + > > test_done > > diff --git a/ui-snapshot.c b/ui-snapshot.c > > index 8f82119..ab20a4a 100644 > > --- a/ui-snapshot.c > > +++ b/ui-snapshot.c > > @@ -205,7 +205,7 @@ void cgit_print_snapshot(const char *head, const char > > *hex, > > } > > > > f = get_format(filename); > > - if (!f) { > > + if (!f || (snapshots & f->bit) == 0) { > > show_error("Unsupported snapshot format: %s", filename); > > return; > > } ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH] Disallow downloading disabled snapshot formats
We did only display enabled snapshot formats but we did not prevent from downloading disabled formats when requested. Fix this by adding an appropriate check. Also, add a test case that checks whether downloading disabled snapshot formats is denied, as expected. Signed-off-by: Lukas Fleischer --- tests/t0107-snapshot.sh | 5 + ui-snapshot.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index 6cf7aaa..01e8d22 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh @@ -79,4 +79,9 @@ test_expect_success UNZIP 'verify unzipped file-5' ' test_line_count = 1 master/file-5 ' +test_expect_success 'try to download a disabled snapshot format' ' + cgit_url "foo/snapshot/master.tar.xz" | + grep "Unsupported snapshot format" +' + test_done diff --git a/ui-snapshot.c b/ui-snapshot.c index 8f82119..ab20a4a 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -205,7 +205,7 @@ void cgit_print_snapshot(const char *head, const char *hex, } f = get_format(filename); - if (!f) { + if (!f || (snapshots & f->bit) == 0) { show_error("Unsupported snapshot format: %s", filename); return; } -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 2/2] cgit.c: Fix comment on bit mask hack
* Formatting and spelling fixes. * A bit mask with the size of one byte only allows for storing 8 (not 255!) different flags. Signed-off-by: Lukas Fleischer --- cgit.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cgit.c b/cgit.c index f4262d8..d74b0f3 100644 --- a/cgit.c +++ b/cgit.c @@ -885,14 +885,16 @@ static void cgit_parse_args(int argc, const char **argv) ctx.qry.ofs = atoi(argv[i] + 6); } else if (!prefixcmp(argv[i], "--scan-tree=") || !prefixcmp(argv[i], "--scan-path=")) { - /* HACK: the global snapshot bitmask defines the -* set of allowed snapshot formats, but the config -* file hasn't been parsed yet so the mask is -* currently 0. By setting all bits high before -* scanning we make sure that any in-repo cgitrc -* snapshot setting is respected by scan_tree(). -* BTW: we assume that there'll never be more than -* 255 different snapshot formats supported by cgit... + /* +* HACK: The global snapshot bit mask defines the set +* of allowed snapshot formats, but the config file +* hasn't been parsed yet so the mask is currently 0. +* By setting all bits high before scanning we make +* sure that any in-repo cgitrc snapshot setting is +* respected by scan_tree(). +* +* NOTE: We assume that there aren't more than 8 +* different snapshot formats supported by cgit... */ ctx.cfg.snapshots = 0xFF; scan++; -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 1/2] cgit.c: Use "else" for mutually exclusive branches
When parsing command line arguments, no pair of command line options can ever match simultaneously. Use "else if" blocks to reflect this. This change improves both readability and speed. Signed-off-by: Lukas Fleischer --- Based on the patches I sent earlier today. cgit.c | 29 ++--- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/cgit.c b/cgit.c index e31962d..f4262d8 100644 --- a/cgit.c +++ b/cgit.c @@ -865,35 +865,26 @@ static void cgit_parse_args(int argc, const char **argv) for (i = 1; i < argc; i++) { if (!prefixcmp(argv[i], "--cache=")) { ctx.cfg.cache_root = xstrdup(argv[i] + 8); - } - if (!strcmp(argv[i], "--nocache")) { + } else if (!strcmp(argv[i], "--nocache")) { ctx.cfg.nocache = 1; - } - if (!strcmp(argv[i], "--nohttp")) { + } else if (!strcmp(argv[i], "--nohttp")) { ctx.env.no_http = "1"; - } - if (!prefixcmp(argv[i], "--query=")) { + } else if (!prefixcmp(argv[i], "--query=")) { ctx.qry.raw = xstrdup(argv[i] + 8); - } - if (!prefixcmp(argv[i], "--repo=")) { + } else if (!prefixcmp(argv[i], "--repo=")) { ctx.qry.repo = xstrdup(argv[i] + 7); - } - if (!prefixcmp(argv[i], "--page=")) { + } else if (!prefixcmp(argv[i], "--page=")) { ctx.qry.page = xstrdup(argv[i] + 7); - } - if (!prefixcmp(argv[i], "--head=")) { + } else if (!prefixcmp(argv[i], "--head=")) { ctx.qry.head = xstrdup(argv[i] + 7); ctx.qry.has_symref = 1; - } - if (!prefixcmp(argv[i], "--sha1=")) { + } else if (!prefixcmp(argv[i], "--sha1=")) { ctx.qry.sha1 = xstrdup(argv[i] + 7); ctx.qry.has_sha1 = 1; - } - if (!prefixcmp(argv[i], "--ofs=")) { + } else if (!prefixcmp(argv[i], "--ofs=")) { ctx.qry.ofs = atoi(argv[i] + 6); - } - if (!prefixcmp(argv[i], "--scan-tree=") || - !prefixcmp(argv[i], "--scan-path=")) { + } else if (!prefixcmp(argv[i], "--scan-tree=") || + !prefixcmp(argv[i], "--scan-path=")) { /* HACK: the global snapshot bitmask defines the * set of allowed snapshot formats, but the config * file hasn't been parsed yet so the mask is -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 4/4] ui-snapshot.c: Do not reinvent suffixcmp()
Use suffixcmp() from Git instead of reimplementing it. This is a preparation for moving to ends_with() in Git 1.8.6. Signed-off-by: Lukas Fleischer --- ui-snapshot.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ui-snapshot.c b/ui-snapshot.c index 901c0c9..8f82119 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -98,14 +98,9 @@ const struct cgit_snapshot_format cgit_snapshot_formats[] = { static const struct cgit_snapshot_format *get_format(const char *filename) { const struct cgit_snapshot_format *fmt; - int fl, sl; - fl = strlen(filename); for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) { - sl = strlen(fmt->suffix); - if (sl >= fl) - continue; - if (!strcmp(fmt->suffix, filename + fl - sl)) + if (!suffixcmp(filename, fmt->suffix)) return fmt; } return NULL; -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 3/4] Refactor cgit_parse_snapshots_mask()
Use Git string lists instead of str{spn,cspn,ncmp}() magic. This significantly improves readability. Signed-off-by: Lukas Fleischer --- shared.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/shared.c b/shared.c index 1f6310a..01197f1 100644 --- a/shared.c +++ b/shared.c @@ -404,28 +404,29 @@ void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix) int cgit_parse_snapshots_mask(const char *str) { + struct string_list tokens = STRING_LIST_INIT_DUP; + struct string_list_item *item; const struct cgit_snapshot_format *f; - static const char *delim = " "; - int tl, sl, rv = 0; + int rv = 0; /* favor legacy setting */ if (atoi(str)) return 1; - for (;;) { - str += strspn(str, delim); - tl = strcspn(str, delim); - if (!tl) - break; + + string_list_split(&tokens, str, ' ', -1); + string_list_remove_empty_items(&tokens, 0); + + for_each_string_list_item(item, &tokens) { for (f = cgit_snapshot_formats; f->suffix; f++) { - sl = strlen(f->suffix); - if ((tl == sl && !strncmp(f->suffix, str, tl)) || - (tl == sl - 1 && !strncmp(f->suffix + 1, str, tl - 1))) { + if (!strcmp(item->string, f->suffix) || + !strcmp(item->string, f->suffix + 1)) { rv |= f->bit; break; } } - str += tl; } + + string_list_clear(&tokens, 0); return rv; } -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 2/4] Disallow use of undocumented snapshot delimiters
Since the introduction of selective snapshot format configuration in dc3c9b5 (allow selective enabling of snapshots, 2007-07-21), we allowed seven different delimiters for snapshot formats, while the documentation has always been clear about spaces being the only valid delimiter: The value is a space-separated list of zero or more of the values "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip". Supporting the undocumented delimiters makes the code unnecessarily complex. Remove them. Signed-off-by: Lukas Fleischer --- shared.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared.c b/shared.c index c5c4b00..1f6310a 100644 --- a/shared.c +++ b/shared.c @@ -405,7 +405,7 @@ void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix) int cgit_parse_snapshots_mask(const char *str) { const struct cgit_snapshot_format *f; - static const char *delim = " \t,:/|;"; + static const char *delim = " "; int tl, sl, rv = 0; /* favor legacy setting */ -- 1.8.5.2 ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
[PATCH 1/4] Replace most uses of strncmp() with prefixcmp()
This is a preparation for replacing all prefix checks with either strip_prefix() or starts_with() when Git 1.8.6 is released. Signed-off-by: Lukas Fleischer --- cgit.c | 18 +- parsing.c| 12 ++-- scan-tree.c | 2 +- ui-refs.c| 4 ++-- ui-shared.c | 2 +- ui-summary.c | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cgit.c b/cgit.c index 1f84da8..e31962d 100644 --- a/cgit.c +++ b/cgit.c @@ -863,7 +863,7 @@ static void cgit_parse_args(int argc, const char **argv) int scan = 0; for (i = 1; i < argc; i++) { - if (!strncmp(argv[i], "--cache=", 8)) { + if (!prefixcmp(argv[i], "--cache=")) { ctx.cfg.cache_root = xstrdup(argv[i] + 8); } if (!strcmp(argv[i], "--nocache")) { @@ -872,28 +872,28 @@ static void cgit_parse_args(int argc, const char **argv) if (!strcmp(argv[i], "--nohttp")) { ctx.env.no_http = "1"; } - if (!strncmp(argv[i], "--query=", 8)) { + if (!prefixcmp(argv[i], "--query=")) { ctx.qry.raw = xstrdup(argv[i] + 8); } - if (!strncmp(argv[i], "--repo=", 7)) { + if (!prefixcmp(argv[i], "--repo=")) { ctx.qry.repo = xstrdup(argv[i] + 7); } - if (!strncmp(argv[i], "--page=", 7)) { + if (!prefixcmp(argv[i], "--page=")) { ctx.qry.page = xstrdup(argv[i] + 7); } - if (!strncmp(argv[i], "--head=", 7)) { + if (!prefixcmp(argv[i], "--head=")) { ctx.qry.head = xstrdup(argv[i] + 7); ctx.qry.has_symref = 1; } - if (!strncmp(argv[i], "--sha1=", 7)) { + if (!prefixcmp(argv[i], "--sha1=")) { ctx.qry.sha1 = xstrdup(argv[i] + 7); ctx.qry.has_sha1 = 1; } - if (!strncmp(argv[i], "--ofs=", 6)) { + if (!prefixcmp(argv[i], "--ofs=")) { ctx.qry.ofs = atoi(argv[i] + 6); } - if (!strncmp(argv[i], "--scan-tree=", 12) || - !strncmp(argv[i], "--scan-path=", 12)) { + if (!prefixcmp(argv[i], "--scan-tree=") || + !prefixcmp(argv[i], "--scan-path=")) { /* HACK: the global snapshot bitmask defines the * set of allowed snapshot formats, but the config * file hasn't been parsed yet so the mask is diff --git a/parsing.c b/parsing.c index 248b6ee..d740d38 100644 --- a/parsing.c +++ b/parsing.c @@ -142,25 +142,25 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) if (p == NULL) return ret; - if (strncmp(p, "tree ", 5)) + if (prefixcmp(p, "tree ")) die("Bad commit: %s", sha1_to_hex(commit->object.sha1)); else p += 46; // "tree " + hex[40] + "\n" - while (!strncmp(p, "parent ", 7)) + while (!prefixcmp(p, "parent ")) p += 48; // "parent " + hex[40] + "\n" - if (p && !strncmp(p, "author ", 7)) { + if (p && !prefixcmp(p, "author ")) { p = parse_user(p + 7, &ret->author, &ret->author_email, &ret->author_date); } - if (p && !strncmp(p, "committer ", 9)) { + if (p && !prefixcmp(p, "committer ")) { p = parse_user(p + 9, &ret->committer, &ret->committer_email, &ret->committer_date); } - if (p && !strncmp(p, "encoding ", 9)) { + if (p && !prefixcmp(p, "encoding ")) { p += 9; t = strchr(p, '\n'); if (t) { @@ -239,7 +239,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) if (*p == '\n') break; - if (!strncmp(p, "tagger ", 7)) { + if (!prefixcmp(p, "tagger ")) { p = parse_user(p + 7, &ret->tagger, &ret->tagger_email, &ret->tagger_date); } else { diff --git a/scan-tree.c b/scan-tree.c index 1a2ea87..49de658 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -105,7 +105,7 @@ static void add_repo(co
Re: Welcome on board Lukas Fleischer
On Wed, 08 Jan 2014 at 15:34:10, Jason A. Donenfeld wrote: > Hey folks, > > To speed things up with the merges and reviews of patches on this > list, I've given Lukas Fleischer commit access. He's going to be > helping me maintain the project. We'll each be merging and committing > patches to jd/staging and lf/staging, and from there onto master. I'll > be updating the documentation to reflect this process. Lukas is also > preparing a patch that merges copyright headers and adds an AUTHORS > file with significant contributors. > > If your patch has gotten lost in the queue in the last few months, now > would be a good time to resubmit. I expect to release a new version > before the end of the month. > > Jason > ___ > CGit mailing list > CGit@lists.zx2c4.com > http://lists.zx2c4.com/mailman/listinfo/cgit ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit
Re: RFE: author/committer/tagger links (enable cgit to show gravatar for author, committer and tagger)
On Thu, 09 Jan 2014 at 20:23:04, John Keeping wrote: > [...] > Presumably this would just pass the "A. U. Thor " > string to the filter and we could just map that to the output. > [...] > We could take an incremental approach like git-check-attr and friends do > when GIT_FLUSH=1, but I'm not sure how well we could delimit the output > in that case - I doubt a single line would be sufficient for all cases. > If we're not careful that approach could end up with capability flags > and other complex things like the fast-import protocol. These ideas sound good to me -- much better than the initial Gravatar approach -- presumed they can be implemented efficiently. In case the choice of a delimiter becomes a problem, we could add another option to switch between newline ("\n") and null character ("\0"), or even allow for specifying a custom delimiter. > > My gut feeling is that it /should/ be OK because CGit's caching layer > means that we don't actually regenerate pages too often and CGit tends > to be blazingly fast anyway, but it would be interesting to see some > benchmarks of how much overhead a call to "true" adds. Agreed. ___ CGit mailing list CGit@lists.zx2c4.com http://lists.zx2c4.com/mailman/listinfo/cgit