From b0fc647fe61c19338aec65ffcab513cc84599b18 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 13 Jul 2018 21:44:50 +0200 Subject: filters: generate anchor links from markdown This makes the markdown filter generate anchor links for headings. Signed-off-by: Christian Hesse Tested-by: jean-christophe manciot --- filters/html-converters/md2html | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html index ebf3856..dc20f42 100755 --- a/filters/html-converters/md2html +++ b/filters/html-converters/md2html @@ -3,6 +3,7 @@ import markdown import sys import io from pygments.formatters import HtmlFormatter +from markdown.extensions.toc import TocExtension sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') sys.stdout.write(''' @@ -48,10 +49,14 @@ sys.stdout.write(''' line-height: 1; padding-left: 0; margin-left: -22px; - top: 15%} + top: 15%; +} .markdown-body h1:hover a.anchor .mini-icon-link, .markdown-body h2:hover a.anchor .mini-icon-link, .markdown-body h3:hover a.anchor .mini-icon-link, .markdown-body h4:hover a.anchor .mini-icon-link, .markdown-body h5:hover a.anchor .mini-icon-link, .markdown-body h6:hover a.anchor .mini-icon-link { display: inline-block; } +div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#cgit .markdown-body h3 a.toclink, div#cgit .markdown-body h4 a.toclink, div#cgit .markdown-body h5 a.toclink, div#cgit .markdown-body h6 a.toclink { + color: black; +} .markdown-body h1 tt, .markdown-body h1 code, .markdown-body h2 tt, .markdown-body h2 code, .markdown-body h3 tt, .markdown-body h3 code, .markdown-body h4 tt, .markdown-body h4 code, .markdown-body h5 tt, .markdown-body h5 code, .markdown-body h6 tt, .markdown-body h6 code { font-size: inherit; } @@ -290,5 +295,13 @@ sys.stdout.write(''' sys.stdout.write("
") sys.stdout.flush() # Note: you may want to run this through bleach for sanitization -markdown.markdownFromFile(output_format="html5", extensions=["markdown.extensions.fenced_code", "markdown.extensions.codehilite", "markdown.extensions.tables"], extension_configs={"markdown.extensions.codehilite":{"css_class":"highlight"}}) +markdown.markdownFromFile( + output_format="html5", + extensions=[ + "markdown.extensions.fenced_code", + "markdown.extensions.codehilite", + "markdown.extensions.tables", + TocExtension(anchorlink=True)], + extension_configs={ + "markdown.extensions.codehilite":{"css_class":"highlight"}}) sys.stdout.write("
") -- cgit v1.2.3-24-g4f1b From 7cde5885d8ce53359ee665bb930b1da956e8369a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 18:11:50 +0200 Subject: parsing: ban strncpy() Git upstream bans strncpy() with commit: banned.h: mark strncpy() as banned e488b7aba743d23b830d239dcc33d9ca0745a9ad Signed-off-by: Christian Hesse --- parsing.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/parsing.c b/parsing.c index 12453c2..e224564 100644 --- a/parsing.c +++ b/parsing.c @@ -63,8 +63,7 @@ static char *substr(const char *head, const char *tail) if (tail < head) return xstrdup(""); buf = xmalloc(tail - head + 1); - strncpy(buf, head, tail - head); - buf[tail - head] = '\0'; + strlcpy(buf, head, tail - head + 1); return buf; } -- cgit v1.2.3-24-g4f1b From 60a930044d57faae4fcb84cba9d85310b0c767a7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 18:14:32 +0200 Subject: parsing: ban sprintf() Git upstream bans sprintf() with commit: banned.h: mark sprintf() as banned cc8fdaee1eeaf05d8dd55ff11f111b815f673c58 Signed-off-by: Christian Hesse --- parsing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsing.c b/parsing.c index e224564..9e73e70 100644 --- a/parsing.c +++ b/parsing.c @@ -77,7 +77,7 @@ static void parse_user(const char *t, char **name, char **email, unsigned long * email_len = ident.mail_end - ident.mail_begin; *email = xmalloc(strlen("<") + email_len + strlen(">") + 1); - sprintf(*email, "<%.*s>", email_len, ident.mail_begin); + xsnprintf(*email, email_len + 3, "<%.*s>", email_len, ident.mail_begin); if (ident.date_begin) *date = strtoul(ident.date_begin, NULL, 10); -- cgit v1.2.3-24-g4f1b From 71ba7187e5eeeaf2f66bc27bc3b48a2014d37bb7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 18:08:33 +0200 Subject: ui-log: ban strcpy() Git upstream bans strcpy() with commit: automatically ban strcpy() c8af66ab8ad7cd78557f0f9f5ef6a52fd46ee6dd Signed-off-by: Christian Hesse --- ui-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-log.c b/ui-log.c index d696e20..c2f92fe 100644 --- a/ui-log.c +++ b/ui-log.c @@ -234,7 +234,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs) strbuf_add(&msgbuf, "\n\n", 2); /* Place wrap_symbol at position i in info->subject */ - strcpy(info->subject + i, wrap_symbol); + strlcpy(info->subject + i, wrap_symbol, subject_len - i + 1); } } cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, -- cgit v1.2.3-24-g4f1b From 7f75647b5565076b70d7c619df08e6c64dac9386 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 18:16:11 +0200 Subject: ui-log: ban strncpy() Git upstream bans strncpy() with commit: banned.h: mark strncpy() as banned e488b7aba743d23b830d239dcc33d9ca0745a9ad Signed-off-by: Christian Hesse --- ui-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-log.c b/ui-log.c index c2f92fe..3bcb657 100644 --- a/ui-log.c +++ b/ui-log.c @@ -67,7 +67,7 @@ void show_commit_decorations(struct commit *commit) while (deco) { struct object_id peeled; int is_annotated = 0; - strncpy(buf, prettify_refname(deco->name), sizeof(buf) - 1); + strlcpy(buf, prettify_refname(deco->name), sizeof(buf)); switch(deco->type) { case DECORATION_NONE: /* If the git-core doesn't recognize it, -- cgit v1.2.3-24-g4f1b From edb3403f00f14ac5cc23b9ba3a122cb4ee8b81fa Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 18:18:37 +0200 Subject: ui-patch: ban sprintf() Git upstream bans sprintf() with commit: banned.h: mark sprintf() as banned cc8fdaee1eeaf05d8dd55ff11f111b815f673c58 Signed-off-by: Christian Hesse --- ui-patch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui-patch.c b/ui-patch.c index 8007a11..82f125b 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -11,13 +11,16 @@ #include "html.h" #include "ui-shared.h" +/* two commit hashes with two dots in between and termination */ +#define REV_RANGE_LEN 2 * GIT_MAX_HEXSZ + 3 + void cgit_print_patch(const char *new_rev, const char *old_rev, const char *prefix) { struct rev_info rev; struct commit *commit; struct object_id new_rev_oid, old_rev_oid; - char rev_range[2 * 40 + 3]; + char rev_range[REV_RANGE_LEN]; const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix, NULL }; int rev_argc = ARRAY_SIZE(rev_argv) - 1; char *patchname; @@ -60,7 +63,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (is_null_oid(&old_rev_oid)) { memcpy(rev_range, oid_to_hex(&new_rev_oid), GIT_SHA1_HEXSZ + 1); } else { - sprintf(rev_range, "%s..%s", oid_to_hex(&old_rev_oid), + xsnprintf(rev_range, REV_RANGE_LEN, "%s..%s", oid_to_hex(&old_rev_oid), oid_to_hex(&new_rev_oid)); } -- cgit v1.2.3-24-g4f1b From 2fc008d6dea2456548825c973a5516b5cdfd9c8c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 20:33:02 +0200 Subject: ui-shared: ban strcat() Git upstream bans strcat() with commit: banned.h: mark strcat() as banned 1b11b64b815db62f93a04242e4aed5687a448748 To avoid compiler warnings from gcc 8.1.x we get the hard way. Signed-off-by: Christian Hesse --- ui-shared.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui-shared.c b/ui-shared.c index 739505a..b53c56d 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1159,7 +1159,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, void cgit_set_title_from_path(const char *path) { - size_t path_len, path_index, path_last_end; + size_t path_len, path_index, path_last_end, line_len; char *new_title; if (!path) @@ -1176,14 +1176,18 @@ void cgit_set_title_from_path(const char *path) continue; } strncat(new_title, &path[path_index + 1], path_last_end - path_index - 1); - strcat(new_title, "\\"); + line_len = strlen(new_title); + new_title[line_len++] = '\\'; + new_title[line_len] = '\0'; path_last_end = path_index; } } if (path_last_end) strncat(new_title, path, path_last_end); - strcat(new_title, " - "); - strcat(new_title, ctx.page.title); + line_len = strlen(new_title); + memcpy(&new_title[line_len], " - ", 3); + new_title[line_len + 3] = '\0'; + strncat(new_title, ctx.page.title, sizeof(new_title) - strlen(new_title) - 1); ctx.page.title = new_title; } -- cgit v1.2.3-24-g4f1b From 0899eb644fab415e9a3b304f53da9da50aaf91aa Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 18:22:26 +0200 Subject: ui-ssdiff: ban strncpy() Git upstream bans strncpy() with commit: banned.h: mark strncpy() as banned e488b7aba743d23b830d239dcc33d9ca0745a9ad Signed-off-by: Christian Hesse --- ui-ssdiff.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui-ssdiff.c b/ui-ssdiff.c index 68c2044..a3dd059 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c @@ -103,8 +103,7 @@ static int line_from_hunk(char *line, char type) return 0; len = buf2 - buf1; buf2 = xmalloc(len + 1); - strncpy(buf2, buf1, len); - buf2[len] = '\0'; + strlcpy(buf2, buf1, len + 1); res = atoi(buf2); free(buf2); return res; -- cgit v1.2.3-24-g4f1b From a96f2890f41e0b9b0ffa1bcdb1dddbef28c01662 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 18:23:36 +0200 Subject: ui-ssdiff: ban strcat() Git upstream bans strcat() with commit: banned.h: mark strcat() as banned 1b11b64b815db62f93a04242e4aed5687a448748 Signed-off-by: Christian Hesse --- ui-ssdiff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui-ssdiff.c b/ui-ssdiff.c index a3dd059..c456033 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c @@ -117,6 +117,7 @@ static char *replace_tabs(char *line) int n_tabs = 0; int i; char *result; + int result_len; if (linelen == 0) { result = xmalloc(1); @@ -128,13 +129,14 @@ static char *replace_tabs(char *line) if (line[i] == '\t') n_tabs += 1; } - result = xmalloc(linelen + n_tabs * 8 + 1); + result_len = linelen + n_tabs * 8; + result = xmalloc(result_len + 1); result[0] = '\0'; for (;;) { cur_buf = strchr(prev_buf, '\t'); if (!cur_buf) { - strcat(result, prev_buf); + strncat(result, prev_buf, result_len); break; } else { strncat(result, prev_buf, cur_buf - prev_buf); -- cgit v1.2.3-24-g4f1b From 2c9f56f3e1c754f60ccffbc6c745b9d5a81ea005 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 28 Aug 2018 18:27:00 +0200 Subject: git: update to v2.19.1 Update to git version v2.19.1. Required changes follow upstream commits: * commit: add repository argument to get_cached_commit_buffer (3ce85f7e5a41116145179f0fae2ce6d86558d099) * commit: add repository argument to lookup_commit_reference (2122f6754c93be8f02bfb5704ed96c88fc9837a8) * object: add repository argument to parse_object (109cd76dd3467bd05f8d2145b857006649741d5c) * tag: add repository argument to deref_tag (a74093da5ed601a09fa158e5ba6f6f14c1142a3e) * tag: add repository argument to lookup_tag (ce71efb713f97f476a2d2ab541a0c73f684a5db3) * tree: add repository argument to lookup_tree (f86bcc7b2ce6cad68ba1a48a528e380c6126705e) * archive.c: avoid access to the_index (b612ee202a48f129f81f8f6a5af6cf71d1a9caef) * for_each_*_object: move declarations to object-store.h (0889aae1cd18c1804ba01c1a4229e516dfb9fe9b) Signed-off-by: Christian Hesse --- Makefile | 2 +- cgit.h | 1 + git | 2 +- parsing.c | 2 +- shared.c | 2 +- ui-blame.c | 2 +- ui-blob.c | 6 +++--- ui-clone.c | 4 ++-- ui-commit.c | 4 ++-- ui-diff.c | 4 ++-- ui-patch.c | 4 ++-- ui-plain.c | 2 +- ui-snapshot.c | 4 ++-- ui-tag.c | 4 ++-- ui-tree.c | 4 ++-- 15 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 05ea71f..1c49b50 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.18.0 +GIT_VER = 2.19.1 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz INSTALL = install COPYTREE = cp -r diff --git a/cgit.h b/cgit.h index 32dfd7a..bcc4fce 100644 --- a/cgit.h +++ b/cgit.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/git b/git index 53f9a3e..cae598d 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 53f9a3e157dbbc901a02ac2c73346d375e24978c +Subproject commit cae598d9980661a978e2df4fb338518f7bf09572 diff --git a/parsing.c b/parsing.c index 9e73e70..7b3980e 100644 --- a/parsing.c +++ b/parsing.c @@ -129,7 +129,7 @@ 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 *p = get_cached_commit_buffer(the_repository, commit, NULL); const char *t; ret = xcalloc(1, sizeof(struct commitinfo)); diff --git a/shared.c b/shared.c index 609bd2a..7560f5f 100644 --- a/shared.c +++ b/shared.c @@ -161,7 +161,7 @@ static struct refinfo *cgit_mk_refinfo(const char *refname, const struct object_ ref = xmalloc(sizeof (struct refinfo)); ref->refname = xstrdup(refname); - ref->object = parse_object(oid); + ref->object = parse_object(the_repository, oid); switch (ref->object->type) { case OBJ_TAG: ref->tag = cgit_parse_tag((struct tag *)ref->object); diff --git a/ui-blame.c b/ui-blame.c index 50d0580..6dc555f 100644 --- a/ui-blame.c +++ b/ui-blame.c @@ -278,7 +278,7 @@ void cgit_print_blame(void) "Invalid revision name: %s", rev); return; } - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit || parse_commit(commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); diff --git a/ui-blob.c b/ui-blob.c index 7b6da2a..4b6b462 100644 --- a/ui-blob.c +++ b/ui-blob.c @@ -56,7 +56,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) goto done; if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) goto done; - read_tree_recursive(lookup_commit_reference(&oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(lookup_commit_reference(the_repository, &oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); done: free(path_items.match); @@ -89,7 +89,7 @@ int cgit_print_file(char *path, const char *head, int file_only) return -1; type = oid_object_info(the_repository, &oid, &size); if (type == OBJ_COMMIT) { - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.found_path) return -1; @@ -145,7 +145,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl type = oid_object_info(the_repository, &oid, &size); if ((!hex) && type == OBJ_COMMIT && path) { - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); type = oid_object_info(the_repository, &oid, &size); } diff --git a/ui-clone.c b/ui-clone.c index 6ba8f36..5dccb63 100644 --- a/ui-clone.c +++ b/ui-clone.c @@ -19,12 +19,12 @@ static int print_ref_info(const char *refname, const struct object_id *oid, { struct object *obj; - if (!(obj = parse_object(oid))) + if (!(obj = parse_object(the_repository, oid))) return 0; htmlf("%s\t%s\n", oid_to_hex(oid), refname); if (obj->type == OBJ_TAG) { - if (!(obj = deref_tag(obj, refname, 0))) + if (!(obj = deref_tag(the_repository, obj, refname, 0))) return 0; htmlf("%s\t%s^{}\n", oid_to_hex(&obj->oid), refname); } diff --git a/ui-commit.c b/ui-commit.c index 995cb93..9a47b54 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -31,7 +31,7 @@ void cgit_print_commit(char *hex, const char *prefix) "Bad object id: %s", hex); return; } - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit) { cgit_print_error_page(404, "Not found", "Bad commit reference: %s", hex); @@ -87,7 +87,7 @@ void cgit_print_commit(char *hex, const char *prefix) free(tmp); html("\n"); for (p = commit->parents; p; p = p->next) { - parent = lookup_commit_reference(&p->item->object.oid); + parent = lookup_commit_reference(the_repository, &p->item->object.oid); if (!parent) { html(""); cgit_print_error("Error reading parent commit"); diff --git a/ui-diff.c b/ui-diff.c index e33e9fb..70dcc91 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -407,7 +407,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, "Bad object name: %s", new_rev); return; } - commit = lookup_commit_reference(new_rev_oid); + commit = lookup_commit_reference(the_repository, new_rev_oid); if (!commit || parse_commit(commit)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(new_rev_oid)); @@ -428,7 +428,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, } if (!is_null_oid(old_rev_oid)) { - commit2 = lookup_commit_reference(old_rev_oid); + commit2 = lookup_commit_reference(the_repository, old_rev_oid); if (!commit2 || parse_commit(commit2)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(old_rev_oid)); diff --git a/ui-patch.c b/ui-patch.c index 82f125b..5a96410 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -36,7 +36,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, "Bad object id: %s", new_rev); return; } - commit = lookup_commit_reference(&new_rev_oid); + commit = lookup_commit_reference(the_repository, &new_rev_oid); if (!commit) { cgit_print_error_page(404, "Not found", "Bad commit reference: %s", new_rev); @@ -49,7 +49,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, "Bad object id: %s", old_rev); return; } - if (!lookup_commit_reference(&old_rev_oid)) { + if (!lookup_commit_reference(the_repository, &old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad commit reference: %s", old_rev); return; diff --git a/ui-plain.c b/ui-plain.c index ddb3e48..070c34b 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -185,7 +185,7 @@ void cgit_print_plain(void) cgit_print_error_page(404, "Not found", "Not found"); return; } - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit || parse_commit(commit)) { cgit_print_error_page(404, "Not found", "Not found"); return; diff --git a/ui-snapshot.c b/ui-snapshot.c index fa3ceaf..85efe64 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -37,7 +37,7 @@ static int write_archive_type(const char *format, const char *hex, const char *p /* argv_array guarantees a trailing NULL entry. */ memcpy(nargv, argv.argv, sizeof(char *) * (argv.argc + 1)); - result = write_archive(argv.argc, nargv, NULL, NULL, 0); + result = write_archive(argv.argc, nargv, NULL, the_repository, NULL, 0); argv_array_clear(&argv); free(nargv); return result; @@ -147,7 +147,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, "Bad object id: %s", hex); return 1; } - if (!lookup_commit_reference(&oid)) { + if (!lookup_commit_reference(the_repository, &oid)) { cgit_print_error_page(400, "Bad request", "Not a commit reference: %s", hex); return 1; diff --git a/ui-tag.c b/ui-tag.c index 2c96c37..f530224 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -53,7 +53,7 @@ void cgit_print_tag(char *revname) "Bad tag reference: %s", revname); goto cleanup; } - obj = parse_object(&oid); + obj = parse_object(the_repository, &oid); if (!obj) { cgit_print_error_page(500, "Internal server error", "Bad object id: %s", oid_to_hex(&oid)); @@ -63,7 +63,7 @@ void cgit_print_tag(char *revname) struct tag *tag; struct taginfo *info; - tag = lookup_tag(&oid); + tag = lookup_tag(the_repository, &oid); if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { cgit_print_error_page(500, "Internal server error", "Bad tag object: %s", revname); diff --git a/ui-tree.c b/ui-tree.c index e6b3074..df8ad82 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -177,7 +177,7 @@ static void write_tree_link(const struct object_id *oid, char *name, cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, fullpath->buf); - tree = lookup_tree(&tree_ctx.oid); + tree = lookup_tree(the_repository, &tree_ctx.oid); if (!tree) return; @@ -359,7 +359,7 @@ void cgit_print_tree(const char *rev, char *path) "Invalid revision name: %s", rev); return; } - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit || parse_commit(commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); -- cgit v1.2.3-24-g4f1b From a22855747e97e55a7b7a2622fe671b8ca9af0981 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 20 Nov 2018 23:55:03 +0100 Subject: git: use xz compressed archive for download Upstream will stop providing gz compressed source tarballs [0], so stop using them. [0] https://lists.zx2c4.com/pipermail/cgit/2018-November/004254.html Signed-off-by: Christian Hesse --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1c49b50..4aaf2dc 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = GIT_VER = 2.19.1 -GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz +GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r MAN5_TXT = $(wildcard *.5.txt) @@ -157,7 +157,7 @@ clean-doc: $(RM) cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo get-git: - curl -L $(GIT_URL) | tar -xzf - && rm -rf git && mv git-$(GIT_VER) git + curl -L $(GIT_URL) | tar -xJf - && rm -rf git && mv git-$(GIT_VER) git tags: $(QUIET_TAGS)find . -name '*.[ch]' | xargs ctags -- cgit v1.2.3-24-g4f1b From 898b9e19e0eacd67456ddcc91ff173055e1c0e99 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 21 Nov 2018 03:16:11 +0100 Subject: auth-filter: pass url with query string attached Otherwise redirections come out wrong. Signed-off-by: Jason A. Donenfeld --- cgit.c | 2 +- ui-shared.c | 37 +++++++++++++++++++++++++++++++++++-- ui-shared.h | 1 + 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/cgit.c b/cgit.c index 6301b87..2f07e6d 100644 --- a/cgit.c +++ b/cgit.c @@ -645,7 +645,7 @@ static inline void open_auth_filter(const char *function) ctx.env.https ? ctx.env.https : "", ctx.qry.repo ? ctx.qry.repo : "", ctx.qry.page ? ctx.qry.page : "", - ctx.qry.url ? ctx.qry.url : "", + cgit_currentfullurl(), cgit_loginurl()); } diff --git a/ui-shared.c b/ui-shared.c index b53c56d..7a4c726 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -68,15 +68,48 @@ char *cgit_hosturl(void) char *cgit_currenturl(void) { const char *root = cgit_rooturl(); - size_t len = strlen(root); if (!ctx.qry.url) return xstrdup(root); - if (len && root[len - 1] == '/') + if (root[0] && root[strlen(root) - 1] == '/') return fmtalloc("%s%s", root, ctx.qry.url); return fmtalloc("%s/%s", root, ctx.qry.url); } +char *cgit_currentfullurl(void) +{ + const char *root = cgit_rooturl(); + const char *orig_query = ctx.env.query_string ? ctx.env.query_string : ""; + size_t len = strlen(orig_query); + char *query = xmalloc(len + 2), *start_url, *ret; + + /* Remove all url=... parts from query string */ + memcpy(query + 1, orig_query, len + 1); + query[0] = '?'; + start_url = query; + while ((start_url = strstr(start_url, "url=")) != NULL) { + if (start_url[-1] == '?' || start_url[-1] == '&') { + const char *end_url = strchr(start_url, '&'); + if (end_url) + memmove(start_url, end_url + 1, strlen(end_url)); + else + start_url[0] = '\0'; + } else + ++start_url; + } + if (!query[1]) + query[0] = '\0'; + + if (!ctx.qry.url) + ret = fmtalloc("%s%s", root, query); + else if (root[0] && root[strlen(root) - 1] == '/') + ret = fmtalloc("%s%s%s", root, ctx.qry.url, query); + else + ret = fmtalloc("%s/%s%s", root, ctx.qry.url, query); + free(query); + return ret; +} + const char *cgit_rooturl(void) { if (ctx.cfg.virtual_root) diff --git a/ui-shared.h b/ui-shared.h index 4d5978b..6964873 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -5,6 +5,7 @@ extern const char *cgit_httpscheme(void); extern char *cgit_hosturl(void); extern const char *cgit_rooturl(void); extern char *cgit_currenturl(void); +extern char *cgit_currentfullurl(void); extern const char *cgit_loginurl(void); extern char *cgit_repourl(const char *reponame); extern char *cgit_fileurl(const char *reponame, const char *pagename, -- cgit v1.2.3-24-g4f1b From 441dac1d747dab43e3559ee68f18a273512064cd Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 22 Nov 2018 01:49:55 +0100 Subject: ui-blame: set repo for sb Otherwise recent git complains and crashes with: "BUG: blame.c:1787: repo is NULL". Signed-off-by: Jason A. Donenfeld --- ui-blame.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui-blame.c b/ui-blame.c index 6dc555f..c52cb9b 100644 --- a/ui-blame.c +++ b/ui-blame.c @@ -131,6 +131,7 @@ static void print_object(const struct object_id *oid, const char *path, setup_revisions(rev_argv.argc, rev_argv.argv, &revs, NULL); init_scoreboard(&sb); sb.revs = &revs; + sb.repo = the_repository; setup_scoreboard(&sb, path, &o); o->suspects = blame_entry_prepend(NULL, 0, sb.num_lines, o); prio_queue_put(&sb.commits, o->commit); -- cgit v1.2.3-24-g4f1b From 55ebd5e97ccd0da9424d68f1e0f301551cf4b47a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 20 Nov 2018 17:31:21 +0100 Subject: git: update to v2.20.0 Update to git version v2.20.0. Required changes follow upstream commits: * 00436bf1b1c2a8fe6cf5d2c2457d419d683042f4 (archive: initialize archivers earlier) * 611e42a5980a3a9f8bb3b1b49c1abde63c7a191e (xdiff: provide a separate emit callback for hunks) Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- shared.c | 2 +- ui-snapshot.c | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4aaf2dc..e690c7f 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.19.1 +GIT_VER = 2.20.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index cae598d..5d826e9 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit cae598d9980661a978e2df4fb338518f7bf09572 +Subproject commit 5d826e972970a784bd7a7bdf587512510097b8c7 diff --git a/shared.c b/shared.c index 7560f5f..a2c0d03 100644 --- a/shared.c +++ b/shared.c @@ -325,7 +325,7 @@ int cgit_diff_files(const struct object_id *old_oid, diff_params.flags |= XDF_IGNORE_WHITESPACE; emit_params.ctxlen = context > 0 ? context : 3; emit_params.flags = XDL_EMIT_FUNCNAMES; - emit_cb.outf = filediff_cb; + emit_cb.out_line = filediff_cb; emit_cb.priv = fn; xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); if (file1.size) diff --git a/ui-snapshot.c b/ui-snapshot.c index 85efe64..9461d51 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -156,6 +156,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, ctx.page.mimetype = xstrdup(format->mimetype); ctx.page.filename = xstrdup(filename); cgit_print_http_headers(); + init_archivers(); format->write_func(hex, prefix); return 0; } -- cgit v1.2.3-24-g4f1b From e23f63461f17aeb770d47d9c3134414e549d1f0e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 2 Jan 2019 07:52:12 +0100 Subject: ui-shared: fix broken sizeof in title setting and rewrite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old algorithm was totally incorrect. While we're at it, use « instead of \, since it makes more sense. Signed-off-by: Jason A. Donenfeld --- ui-shared.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/ui-shared.c b/ui-shared.c index 7a4c726..d27a5fd 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1192,35 +1192,17 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, void cgit_set_title_from_path(const char *path) { - size_t path_len, path_index, path_last_end, line_len; - char *new_title; + struct strbuf sb = STRBUF_INIT; + const char *slash, *last_slash; if (!path) return; - path_len = strlen(path); - new_title = xmalloc(path_len + 3 + strlen(ctx.page.title) + 1); - new_title[0] = '\0'; - - for (path_index = path_len, path_last_end = path_len; path_index-- > 0;) { - if (path[path_index] == '/') { - if (path_index == path_len - 1) { - path_last_end = path_index - 1; - continue; - } - strncat(new_title, &path[path_index + 1], path_last_end - path_index - 1); - line_len = strlen(new_title); - new_title[line_len++] = '\\'; - new_title[line_len] = '\0'; - path_last_end = path_index; - } + for (last_slash = path + strlen(path); (slash = memrchr(path, '/', last_slash - path)) != NULL; last_slash = slash) { + strbuf_add(&sb, slash + 1, last_slash - slash - 1); + strbuf_addstr(&sb, " \xc2\xab "); } - if (path_last_end) - strncat(new_title, path, path_last_end); - - line_len = strlen(new_title); - memcpy(&new_title[line_len], " - ", 3); - new_title[line_len + 3] = '\0'; - strncat(new_title, ctx.page.title, sizeof(new_title) - strlen(new_title) - 1); - ctx.page.title = new_title; + strbuf_add(&sb, path, last_slash - path); + strbuf_addf(&sb, " - %s", ctx.page.title); + ctx.page.title = strbuf_detach(&sb, NULL); } -- cgit v1.2.3-24-g4f1b From 7d87cd3a215976a480b3c71b017a191597e5cb44 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 3 Jan 2019 02:11:14 +0100 Subject: filters: migrate from luacrypto to luaossl luaossl has no upstream anymore and doesn't support OpenSSL 1.1, whereas luaossl is quite active. Signed-off-by: Jason A. Donenfeld --- filters/email-gravatar.lua | 17 +++++++++++++---- filters/email-libravatar.lua | 17 +++++++++++++---- filters/file-authentication.lua | 31 +++++++++++++++++++------------ filters/gentoo-ldap-authentication.lua | 31 +++++++++++++++++++------------ filters/simple-authentication.lua | 31 +++++++++++++++++++------------ 5 files changed, 83 insertions(+), 44 deletions(-) diff --git a/filters/email-gravatar.lua b/filters/email-gravatar.lua index 52cf426..c39b490 100644 --- a/filters/email-gravatar.lua +++ b/filters/email-gravatar.lua @@ -3,15 +3,24 @@ -- prefix in filters. It is much faster than the corresponding python script. -- -- Requirements: --- luacrypto >= 0.3 --- +-- luaossl +-- -- -local crypto = require("crypto") +local digest = require("openssl.digest") + +function md5_hex(input) + local b = digest.new("md5"):final(input) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end function filter_open(email, page) buffer = "" - md5 = crypto.digest("md5", email:sub(2, -2):lower()) + md5 = md5_hex(email:sub(2, -2):lower()) end function filter_close() diff --git a/filters/email-libravatar.lua b/filters/email-libravatar.lua index b0e2447..7336baf 100644 --- a/filters/email-libravatar.lua +++ b/filters/email-libravatar.lua @@ -3,15 +3,24 @@ -- prefix in filters. -- -- Requirements: --- luacrypto >= 0.3 --- +-- luaossl +-- -- -local crypto = require("crypto") +local digest = require("openssl.digest") + +function md5_hex(input) + local b = digest.new("md5"):final(input) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end function filter_open(email, page) buffer = "" - md5 = crypto.digest("md5", email:sub(2, -2):lower()) + md5 = md5_hex(email:sub(2, -2):lower()) end function filter_close() diff --git a/filters/file-authentication.lua b/filters/file-authentication.lua index 6ee1e19..0248804 100644 --- a/filters/file-authentication.lua +++ b/filters/file-authentication.lua @@ -1,15 +1,15 @@ -- This script may be used with the auth-filter. -- -- Requirements: --- luacrypto >= 0.3 --- +-- luaossl +-- -- luaposix -- -- local sysstat = require("posix.sys.stat") local unistd = require("posix.unistd") -local crypto = require("crypto") - +local rand = require("openssl.rand") +local hmac = require("openssl.hmac") -- This file should contain a series of lines in the form of: -- username1:hash1 @@ -225,6 +225,13 @@ function get_cookie(cookies, name) return url_decode(string.match(cookies, ";" .. name .. "=(.-);")) end +function tohex(b) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end -- -- @@ -242,12 +249,12 @@ function get_secret() local secret_file = io.open(secret_filename, "r") if secret_file == nil then local old_umask = sysstat.umask(63) - local temporary_filename = secret_filename .. ".tmp." .. crypto.hex(crypto.rand.bytes(16)) + local temporary_filename = secret_filename .. ".tmp." .. tohex(rand.bytes(16)) local temporary_file = io.open(temporary_filename, "w") if temporary_file == nil then os.exit(177) end - temporary_file:write(crypto.hex(crypto.rand.bytes(32))) + temporary_file:write(tohex(rand.bytes(32))) temporary_file:close() unistd.link(temporary_filename, secret_filename) -- Intentionally fails in the case that another process is doing the same. unistd.unlink(temporary_filename) @@ -272,7 +279,7 @@ function validate_value(expected_field, cookie) local field = "" local expiration = 0 local salt = "" - local hmac = "" + local chmac = "" if cookie == nil or cookie:len() < 3 or cookie:sub(1, 1) == "|" then return nil @@ -291,19 +298,19 @@ function validate_value(expected_field, cookie) elseif i == 3 then salt = component elseif i == 4 then - hmac = component + chmac = component else break end i = i + 1 end - if hmac == nil or hmac:len() == 0 then + if chmac == nil or chmac:len() == 0 then return nil end -- Lua hashes strings, so these comparisons are time invariant. - if hmac ~= crypto.hmac.digest("sha256", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, get_secret()) then + if chmac ~= tohex(hmac.new(get_secret(), "sha256"):final(field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt)) then return nil end @@ -324,11 +331,11 @@ function secure_value(field, value, expiration) end local authstr = "" - local salt = crypto.hex(crypto.rand.bytes(16)) + local salt = tohex(rand.bytes(16)) value = url_encode(value) field = url_encode(field) authstr = field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt - authstr = authstr .. "|" .. crypto.hmac.digest("sha256", authstr, get_secret()) + authstr = authstr .. "|" .. tohex(hmac.new(get_secret(), "sha256"):final(authstr)) return authstr end diff --git a/filters/gentoo-ldap-authentication.lua b/filters/gentoo-ldap-authentication.lua index b4d98c2..673c88d 100644 --- a/filters/gentoo-ldap-authentication.lua +++ b/filters/gentoo-ldap-authentication.lua @@ -1,8 +1,8 @@ -- This script may be used with the auth-filter. Be sure to configure it as you wish. -- -- Requirements: --- luacrypto >= 0.3 --- +-- luaossl +-- -- lualdap >= 1.2 -- -- luaposix @@ -10,9 +10,9 @@ -- local sysstat = require("posix.sys.stat") local unistd = require("posix.unistd") -local crypto = require("crypto") local lualdap = require("lualdap") - +local rand = require("openssl.rand") +local hmac = require("openssl.hmac") -- -- @@ -226,6 +226,13 @@ function get_cookie(cookies, name) return string.match(cookies, ";" .. name .. "=(.-);") end +function tohex(b) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end -- -- @@ -243,12 +250,12 @@ function get_secret() local secret_file = io.open(secret_filename, "r") if secret_file == nil then local old_umask = sysstat.umask(63) - local temporary_filename = secret_filename .. ".tmp." .. crypto.hex(crypto.rand.bytes(16)) + local temporary_filename = secret_filename .. ".tmp." .. tohex(rand.bytes(16)) local temporary_file = io.open(temporary_filename, "w") if temporary_file == nil then os.exit(177) end - temporary_file:write(crypto.hex(crypto.rand.bytes(32))) + temporary_file:write(tohex(rand.bytes(32))) temporary_file:close() unistd.link(temporary_filename, secret_filename) -- Intentionally fails in the case that another process is doing the same. unistd.unlink(temporary_filename) @@ -273,7 +280,7 @@ function validate_value(expected_field, cookie) local field = "" local expiration = 0 local salt = "" - local hmac = "" + local chmac = "" if cookie == nil or cookie:len() < 3 or cookie:sub(1, 1) == "|" then return nil @@ -292,19 +299,19 @@ function validate_value(expected_field, cookie) elseif i == 3 then salt = component elseif i == 4 then - hmac = component + chmac = component else break end i = i + 1 end - if hmac == nil or hmac:len() == 0 then + if chmac == nil or chmac:len() == 0 then return nil end -- Lua hashes strings, so these comparisons are time invariant. - if hmac ~= crypto.hmac.digest("sha256", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, get_secret()) then + if chmac ~= tohex(hmac.new(get_secret(), "sha256"):final(field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt)) then return nil end @@ -325,11 +332,11 @@ function secure_value(field, value, expiration) end local authstr = "" - local salt = crypto.hex(crypto.rand.bytes(16)) + local salt = tohex(rand.bytes(16)) value = url_encode(value) field = url_encode(field) authstr = field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt - authstr = authstr .. "|" .. crypto.hmac.digest("sha256", authstr, get_secret()) + authstr = authstr .. "|" .. tohex(hmac.new(get_secret(), "sha256"):final(authstr)) return authstr end diff --git a/filters/simple-authentication.lua b/filters/simple-authentication.lua index 77d1fd0..23d3457 100644 --- a/filters/simple-authentication.lua +++ b/filters/simple-authentication.lua @@ -1,15 +1,15 @@ -- This script may be used with the auth-filter. Be sure to configure it as you wish. -- -- Requirements: --- luacrypto >= 0.3 --- +-- luaossl +-- -- luaposix -- -- local sysstat = require("posix.sys.stat") local unistd = require("posix.unistd") -local crypto = require("crypto") - +local rand = require("openssl.rand") +local hmac = require("openssl.hmac") -- -- @@ -180,6 +180,13 @@ function get_cookie(cookies, name) return url_decode(string.match(cookies, ";" .. name .. "=(.-);")) end +function tohex(b) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end -- -- @@ -197,12 +204,12 @@ function get_secret() local secret_file = io.open(secret_filename, "r") if secret_file == nil then local old_umask = sysstat.umask(63) - local temporary_filename = secret_filename .. ".tmp." .. crypto.hex(crypto.rand.bytes(16)) + local temporary_filename = secret_filename .. ".tmp." .. tohex(rand.bytes(16)) local temporary_file = io.open(temporary_filename, "w") if temporary_file == nil then os.exit(177) end - temporary_file:write(crypto.hex(crypto.rand.bytes(32))) + temporary_file:write(tohex(rand.bytes(32))) temporary_file:close() unistd.link(temporary_filename, secret_filename) -- Intentionally fails in the case that another process is doing the same. unistd.unlink(temporary_filename) @@ -227,7 +234,7 @@ function validate_value(expected_field, cookie) local field = "" local expiration = 0 local salt = "" - local hmac = "" + local chmac = "" if cookie == nil or cookie:len() < 3 or cookie:sub(1, 1) == "|" then return nil @@ -246,19 +253,19 @@ function validate_value(expected_field, cookie) elseif i == 3 then salt = component elseif i == 4 then - hmac = component + chmac = component else break end i = i + 1 end - if hmac == nil or hmac:len() == 0 then + if chmac == nil or chmac:len() == 0 then return nil end -- Lua hashes strings, so these comparisons are time invariant. - if hmac ~= crypto.hmac.digest("sha256", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, get_secret()) then + if chmac ~= tohex(hmac.new(get_secret(), "sha256"):final(field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt)) then return nil end @@ -279,11 +286,11 @@ function secure_value(field, value, expiration) end local authstr = "" - local salt = crypto.hex(crypto.rand.bytes(16)) + local salt = tohex(rand.bytes(16)) value = url_encode(value) field = url_encode(field) authstr = field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt - authstr = authstr .. "|" .. crypto.hmac.digest("sha256", authstr, get_secret()) + authstr = authstr .. "|" .. tohex(hmac.new(get_secret(), "sha256"):final(authstr)) return authstr end -- cgit v1.2.3-24-g4f1b From 5bd7e9bc1b6749bbb5220d6c3a990469a7b839ae Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Thu, 21 Feb 2019 19:56:05 +0000 Subject: ui-ssdiff: resolve HTML5 validation errors - Remove ids from anchor elements. They were unusable because they were duplicated between files and versions of files. - Always close span, with html(). - Fix missing / on closing tr element in cgit_ssdiff_header_end(). Signed-off-by: Chris Mayo --- ui-ssdiff.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui-ssdiff.c b/ui-ssdiff.c index c456033..b6dc5b0 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c @@ -207,11 +207,13 @@ static void print_part_with_lcs(char *class, char *line, char *lcs) } } else if (line[i] == lcs[j]) { same = 1; - htmlf(""); + html(""); j += 1; } html_txt(c); } + if (!same) + html(""); } static void print_ssdiff_line(char *class, @@ -236,7 +238,7 @@ static void print_ssdiff_line(char *class, char *fileurl = cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str); html("%s", lineno_str, lineno_str + 1); + htmlf("'>%s", lineno_str + 1); html(""); htmlf("", class); free(fileurl); @@ -259,7 +261,7 @@ static void print_ssdiff_line(char *class, char *fileurl = cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str); html("%s", lineno_str, lineno_str + 1); + htmlf("'>%s", lineno_str + 1); html(""); htmlf("", class); free(fileurl); @@ -405,7 +407,7 @@ void cgit_ssdiff_header_begin(void) void cgit_ssdiff_header_end(void) { - html(""); + html(""); } void cgit_ssdiff_footer(void) -- cgit v1.2.3-24-g4f1b From bd0293f57015ede637b630fcaf4fc11e7697d777 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Thu, 21 Feb 2019 19:57:23 +0000 Subject: ui-diff,ui-tag: don't use htmlf with non-formatted strings Signed-off-by: Chris Mayo --- ui-diff.c | 2 +- ui-tag.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui-diff.c b/ui-diff.c index 70dcc91..c60aefd 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -82,7 +82,7 @@ static void print_fileinfo(struct fileinfo *info) } html(""); - htmlf(""); + html(""); if (is_null_oid(info->new_oid)) { cgit_print_filemode(info->old_mode); } else { diff --git a/ui-tag.c b/ui-tag.c index f530224..846d5b1 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -71,7 +71,7 @@ void cgit_print_tag(char *revname) } cgit_print_layout_start(); html("\n"); - htmlf("\n", oid_to_hex(&oid)); if (info->tagger_date > 0) { @@ -103,7 +103,7 @@ void cgit_print_tag(char *revname) } else { cgit_print_layout_start(); html("
tag name"); + html("
tag name"); html_txt(revname); htmlf(" (%s)
\n"); - htmlf("\n"); html("
tag name"); + html("
tag name"); html_txt(revname); html("
tagged object"); -- cgit v1.2.3-24-g4f1b From 54c407a74a35d4ee9ffae94cc5bc9096c9f7f54a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 20 May 2019 21:45:12 +0200 Subject: ui-shared: restrict to 15 levels Perhaps a more ideal version of this would be to not print breadcrumbs at all for paths that don't exist in the given repo at the given oid. Signed-off-by: Jason A. Donenfeld Reported-by: Fydor Wire Snark --- ui-shared.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui-shared.c b/ui-shared.c index d27a5fd..d2358f2 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -945,12 +945,13 @@ static void cgit_print_path_crumbs(char *path) { char *old_path = ctx.qry.path; char *p = path, *q, *end = path + strlen(path); + int levels = 0; ctx.qry.path = NULL; cgit_self_link("root", NULL, NULL); ctx.qry.path = p = path; while (p < end) { - if (!(q = strchr(p, '/'))) + if (!(q = strchr(p, '/')) || levels > 15) q = end; *q = '\0'; html_txt("/"); @@ -958,6 +959,7 @@ static void cgit_print_path_crumbs(char *path) if (q < end) *q = '/'; p = q + 1; + ++levels; } ctx.qry.path = old_path; } -- cgit v1.2.3-24-g4f1b From ccba7eb9d0c43ffe99178ab6632dc3794f887309 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 2 Jan 2019 17:25:01 +0100 Subject: global: make 'char *path' const where possible Signed-off-by: Christian Hesse --- ui-atom.c | 2 +- ui-atom.h | 2 +- ui-log.c | 2 +- ui-log.h | 2 +- ui-refs.c | 2 +- ui-repolist.c | 2 +- ui-summary.c | 2 +- ui-summary.h | 2 +- ui-tree.c | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ui-atom.c b/ui-atom.c index 3866823..cd66f82 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -83,7 +83,7 @@ static void add_entry(struct commit *commit, const char *host) } -void cgit_print_atom(char *tip, char *path, int max_count) +void cgit_print_atom(char *tip, const char *path, int max_count) { char *host; const char *argv[] = {NULL, tip, NULL, NULL, NULL}; diff --git a/ui-atom.h b/ui-atom.h index 749ffd3..dda953b 100644 --- a/ui-atom.h +++ b/ui-atom.h @@ -1,6 +1,6 @@ #ifndef UI_ATOM_H #define UI_ATOM_H -extern void cgit_print_atom(char *tip, char *path, int max_count); +extern void cgit_print_atom(char *tip, const char *path, int max_count); #endif diff --git a/ui-log.c b/ui-log.c index 3bcb657..8c65425 100644 --- a/ui-log.c +++ b/ui-log.c @@ -362,7 +362,7 @@ static char *next_token(char **src) } void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, - char *path, int pager, int commit_graph, int commit_sort) + const char *path, int pager, int commit_graph, int commit_sort) { struct rev_info rev; struct commit *commit; diff --git a/ui-log.h b/ui-log.h index d324c92..325607c 100644 --- a/ui-log.h +++ b/ui-log.h @@ -2,7 +2,7 @@ #define UI_LOG_H extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, - char *pattern, char *path, int pager, + char *pattern, const char *path, int pager, int commit_graph, int commit_sort); extern void show_commit_decorations(struct commit *commit); diff --git a/ui-refs.c b/ui-refs.c index 2ec3858..456f610 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -136,7 +136,7 @@ static int print_tag(struct refinfo *ref) return 0; } -static void print_refs_link(char *path) +static void print_refs_link(const char *path) { html("
"); cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); diff --git a/ui-repolist.c b/ui-repolist.c index 41424c0..7cf7638 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -11,7 +11,7 @@ #include "html.h" #include "ui-shared.h" -static time_t read_agefile(char *path) +static time_t read_agefile(const char *path) { time_t result; size_t size; diff --git a/ui-summary.c b/ui-summary.c index 8e81ac4..947812a 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -99,7 +99,7 @@ static char* append_readme_path(const char *filename, const char *ref, const cha return full_path; } -void cgit_print_repo_readme(char *path) +void cgit_print_repo_readme(const char *path) { char *filename, *ref, *mimetype; int free_filename = 0; diff --git a/ui-summary.h b/ui-summary.h index 0896650..cba696a 100644 --- a/ui-summary.h +++ b/ui-summary.h @@ -2,6 +2,6 @@ #define UI_SUMMARY_H extern void cgit_print_summary(void); -extern void cgit_print_repo_readme(char *path); +extern void cgit_print_repo_readme(const char *path); #endif /* UI_SUMMARY_H */ diff --git a/ui-tree.c b/ui-tree.c index df8ad82..314ac52 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -84,7 +84,7 @@ static void print_binary_buffer(char *buf, unsigned long size) html("
\n"); } -static void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev) +static void print_object(const struct object_id *oid, const char *path, const char *basename, const char *rev) { enum object_type type; char *buf; @@ -279,7 +279,7 @@ static void ls_tail(void) cgit_print_layout_end(); } -static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_context *walk_tree_ctx) +static void ls_tree(const struct object_id *oid, const char *path, struct walk_tree_context *walk_tree_ctx) { struct tree *tree; struct pathspec paths = { -- cgit v1.2.3-24-g4f1b From 68de710c1c0e9b823a156b1398643601a682fbf9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 12 Feb 2019 21:53:02 +0100 Subject: ui-ssdiff: ban strncat() Git version v2.21.0 marks strncat() as banned (commit ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it. Signed-off-by: Christian Hesse --- ui-ssdiff.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui-ssdiff.c b/ui-ssdiff.c index b6dc5b0..af8bc9e 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c @@ -117,7 +117,7 @@ static char *replace_tabs(char *line) int n_tabs = 0; int i; char *result; - int result_len; + size_t result_len; if (linelen == 0) { result = xmalloc(1); @@ -136,10 +136,12 @@ static char *replace_tabs(char *line) for (;;) { cur_buf = strchr(prev_buf, '\t'); if (!cur_buf) { - strncat(result, prev_buf, result_len); + linelen = strlen(result); + strlcpy(&result[linelen], prev_buf, result_len - linelen + 1); break; } else { - strncat(result, prev_buf, cur_buf - prev_buf); + linelen = strlen(result); + strlcpy(&result[linelen], prev_buf, cur_buf - prev_buf + 1); linelen = strlen(result); memset(&result[linelen], ' ', 8 - (linelen % 8)); result[linelen + 8 - (linelen % 8)] = '\0'; -- cgit v1.2.3-24-g4f1b From 985fba80d06f37fdba5e72d738ce21ab5ab5a76d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sun, 24 Feb 2019 21:19:46 +0100 Subject: git: update to v2.21.0 Update to git version v2.21.0. Required changes follow upstream commits: * 6a7895fd8a3bd409f2b71ffc355d5142172cc2a0 (commit: prepare free_commit_buffer and release_commit_memory for any repo) * e092073d643b17c82d72cf692fbfaea9c9796f11 (tree.c: make read_tree*() take 'struct repository *') Signed-off-by: Christian Hesse Reviewed-by: John Keeping --- Makefile | 2 +- git | 2 +- ui-atom.c | 2 +- ui-blame.c | 4 ++-- ui-blob.c | 9 ++++++--- ui-log.c | 4 ++-- ui-plain.c | 3 ++- ui-stats.c | 2 +- ui-tree.c | 10 ++++++---- 9 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index e690c7f..40f4fd8 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.20.0 +GIT_VER = 2.21.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index 5d826e9..8104ec9 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 5d826e972970a784bd7a7bdf587512510097b8c7 +Subproject commit 8104ec994ea3849a968b4667d072fedd1e688642 diff --git a/ui-atom.c b/ui-atom.c index cd66f82..1056f36 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -140,7 +140,7 @@ void cgit_print_atom(char *tip, const char *path, int max_count) } while ((commit = get_revision(&rev)) != NULL) { add_entry(commit, host); - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, commit); free_commit_list(commit->parents); commit->parents = NULL; } diff --git a/ui-blame.c b/ui-blame.c index c52cb9b..644c30a 100644 --- a/ui-blame.c +++ b/ui-blame.c @@ -290,8 +290,8 @@ void cgit_print_blame(void) walk_tree_ctx.match_baselen = (path_items.match) ? basedir_len(path_items.match) : -1; - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, - &walk_tree_ctx); + read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0, + &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.state) cgit_print_error_page(404, "Not found", "Not found"); else if (walk_tree_ctx.state == 2) diff --git a/ui-blob.c b/ui-blob.c index 4b6b462..30e2d4b 100644 --- a/ui-blob.c +++ b/ui-blob.c @@ -56,7 +56,8 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) goto done; if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) goto done; - read_tree_recursive(lookup_commit_reference(the_repository, &oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, lookup_commit_reference(the_repository, &oid)->maybe_tree, + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); done: free(path_items.match); @@ -90,7 +91,8 @@ int cgit_print_file(char *path, const char *head, int file_only) type = oid_object_info(the_repository, &oid, &size); if (type == OBJ_COMMIT) { commit = lookup_commit_reference(the_repository, &oid); - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, commit->maybe_tree, + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.found_path) return -1; type = oid_object_info(the_repository, &oid, &size); @@ -146,7 +148,8 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl if ((!hex) && type == OBJ_COMMIT && path) { commit = lookup_commit_reference(the_repository, &oid); - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, commit->maybe_tree, + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); type = oid_object_info(the_repository, &oid, &size); } diff --git a/ui-log.c b/ui-log.c index 8c65425..dc5cb1e 100644 --- a/ui-log.c +++ b/ui-log.c @@ -488,7 +488,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; /* nop */) { if (show_commit(commit, &rev)) i++; - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, commit); free_commit_list(commit->parents); commit->parents = NULL; } @@ -510,7 +510,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern i++; print_commit(commit, &rev); } - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, commit); free_commit_list(commit->parents); commit->parents = NULL; } diff --git a/ui-plain.c b/ui-plain.c index 070c34b..b73c1cf 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -198,7 +198,8 @@ void cgit_print_plain(void) } else walk_tree_ctx.match_baselen = basedir_len(path_items.match); - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, commit->maybe_tree, + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.match) cgit_print_error_page(404, "Not found", "Not found"); else if (walk_tree_ctx.match == 2) diff --git a/ui-stats.c b/ui-stats.c index 7acd358..7272a61 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -241,7 +241,7 @@ static struct string_list collect_stats(const struct cgit_period *period) memset(&authors, 0, sizeof(authors)); while ((commit = get_revision(&rev)) != NULL) { add_commit(&authors, commit, period); - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, commit); free_commit_list(commit->parents); commit->parents = NULL; } diff --git a/ui-tree.c b/ui-tree.c index 314ac52..4be89c8 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -185,8 +185,8 @@ static void write_tree_link(const struct object_id *oid, char *name, tree_ctx.name = NULL; tree_ctx.count = 0; - read_tree_recursive(tree, "", 0, 1, &paths, single_tree_cb, - &tree_ctx); + read_tree_recursive(the_repository, tree, "", 0, 1, + &paths, single_tree_cb, &tree_ctx); if (tree_ctx.count != 1) break; @@ -294,7 +294,8 @@ static void ls_tree(const struct object_id *oid, const char *path, struct walk_t } ls_head(); - read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx); + read_tree_recursive(the_repository, tree, "", 0, 1, + &paths, ls_item, walk_tree_ctx); ls_tail(); } @@ -373,7 +374,8 @@ void cgit_print_tree(const char *rev, char *path) goto cleanup; } - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0, + &paths, walk_tree, &walk_tree_ctx); if (walk_tree_ctx.state == 1) ls_tail(); else if (walk_tree_ctx.state == 2) -- cgit v1.2.3-24-g4f1b From 27a6d69ab38825602bdbd5a5d0161e465326ea8d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 4 Jun 2019 13:49:36 +0200 Subject: tests: successfully validate rc versions For testing versions the version string differs for git tag (v2.22.0-rc3) and tarball file name (2.22.0.rc3). Let's fix validation for testing versions. Signed-off-by: Christian Hesse --- tests/t0001-validate-git-versions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh index a65b35e..3200f31 100755 --- a/tests/t0001-validate-git-versions.sh +++ b/tests/t0001-validate-git-versions.sh @@ -33,7 +33,7 @@ test_expect_success 'test submodule version matches Makefile' ' sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") && cd git && git describe --match "v[0-9]*" $sm_sha1 - ) | sed -e "s/^v//" >sm_version && + ) | sed -e "s/^v//" -e "s/-/./" >sm_version && test_cmp sm_version makefile_version fi ' -- cgit v1.2.3-24-g4f1b From e1ad15d368bdeb1bffea588b93a29055c5dfb7f4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 26 Feb 2019 17:08:31 +0100 Subject: ui-tree: allow per repository override for enable-blame The blame operation can cause high cost in terms of CPU load for huge repositories. Let's add a per repository override for enable-blame. Signed-off-by: Christian Hesse --- cgit.c | 4 ++++ cgit.h | 1 + cgitrc.5.txt | 4 ++++ cmd.c | 2 +- shared.c | 1 + ui-tree.c | 4 ++-- 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cgit.c b/cgit.c index 2f07e6d..2910d4b 100644 --- a/cgit.c +++ b/cgit.c @@ -50,6 +50,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->extra_head_content = xstrdup(value); else if (!strcmp(name, "snapshots")) repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); + else if (!strcmp(name, "enable-blame")) + repo->enable_blame = atoi(value); else if (!strcmp(name, "enable-commit-graph")) repo->enable_commit_graph = atoi(value); else if (!strcmp(name, "enable-log-filecount")) @@ -809,6 +811,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo) fprintf(f, "repo.homepage=%s\n", repo->homepage); if (repo->clone_url) fprintf(f, "repo.clone-url=%s\n", repo->clone_url); + fprintf(f, "repo.enable-blame=%d\n", + repo->enable_blame); fprintf(f, "repo.enable-commit-graph=%d\n", repo->enable_commit_graph); fprintf(f, "repo.enable-log-filecount=%d\n", diff --git a/cgit.h b/cgit.h index bcc4fce..7ec46b4 100644 --- a/cgit.h +++ b/cgit.h @@ -94,6 +94,7 @@ struct cgit_repo { char *logo_link; char *snapshot_prefix; int snapshots; + int enable_blame; int enable_commit_graph; int enable_log_filecount; int enable_log_linecount; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 34b351b..ba77826 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -485,6 +485,10 @@ repo.email-filter:: Override the default email-filter. Default value: none. See also: "enable-filter-overrides". See also: "FILTER API". +repo.enable-blame:: + A flag which can be used to disable the global setting + `enable-blame'. Default value: none. + repo.enable-commit-graph:: A flag which can be used to disable the global setting `enable-commit-graph'. Default value: none. diff --git a/cmd.c b/cmd.c index 63f0ae5..bf6d8f5 100644 --- a/cmd.c +++ b/cmd.c @@ -66,7 +66,7 @@ static void about_fn(void) static void blame_fn(void) { - if (ctx.cfg.enable_blame) + if (ctx.repo->enable_blame) cgit_print_blame(); else cgit_print_error_page(403, "Forbidden", "Blame is disabled"); diff --git a/shared.c b/shared.c index a2c0d03..8115469 100644 --- a/shared.c +++ b/shared.c @@ -58,6 +58,7 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->homepage = NULL; ret->section = ctx.cfg.section; ret->snapshots = ctx.cfg.snapshots; + ret->enable_blame = ctx.cfg.enable_blame; ret->enable_commit_graph = ctx.cfg.enable_commit_graph; ret->enable_log_filecount = ctx.cfg.enable_log_filecount; ret->enable_log_linecount = ctx.cfg.enable_log_linecount; diff --git a/ui-tree.c b/ui-tree.c index 4be89c8..84eb17d 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -110,7 +110,7 @@ static void print_object(const struct object_id *oid, const char *path, const ch htmlf("blob: %s (", oid_to_hex(oid)); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); - if (ctx.cfg.enable_blame) { + if (ctx.repo->enable_blame) { html(") ("); cgit_blame_link("blame", NULL, NULL, ctx.qry.head, rev, path); @@ -251,7 +251,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, if (!S_ISGITLINK(mode)) cgit_plain_link("plain", NULL, "button", ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf); - if (!S_ISDIR(mode) && ctx.cfg.enable_blame) + if (!S_ISDIR(mode) && ctx.repo->enable_blame) cgit_blame_link("blame", NULL, "button", ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf); html("\n"); -- cgit v1.2.3-24-g4f1b From 034e3c7d56ba71ce281886fe8525b16d4559fac1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 13 May 2019 21:41:37 +0200 Subject: git: update to v2.22.0 Update to git version v2.22.0. Upstream commit bce9db6d ("trace2: use system/global config for default trace2 settings") caused a regression. We have to unset HOME and XDG_CONFIG_HOME before early loading of config from trace2 code kicks in. Signed-off-by: Christian Hesse --- Makefile | 2 +- cgit.c | 17 +++++++++++------ git | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 40f4fd8..b2bd351 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.21.0 +GIT_VER = 2.22.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/cgit.c b/cgit.c index 2910d4b..ac8c641 100644 --- a/cgit.c +++ b/cgit.c @@ -19,6 +19,16 @@ const char *cgit_version = CGIT_VERSION; +__attribute__((constructor)) +static void constructor_environment() +{ + /* Do not look in /etc/ for gitconfig and gitattributes. */ + setenv("GIT_CONFIG_NOSYSTEM", "1", 1); + setenv("GIT_ATTR_NOSYSTEM", "1", 1); + unsetenv("HOME"); + unsetenv("XDG_CONFIG_HOME"); +} + static void add_mimetype(const char *name, const char *value) { struct string_list_item *item; @@ -565,18 +575,13 @@ static void prepare_repo_env(int *nongit) /* The path to the git repository. */ setenv("GIT_DIR", ctx.repo->path, 1); - /* Do not look in /etc/ for gitconfig and gitattributes. */ - setenv("GIT_CONFIG_NOSYSTEM", "1", 1); - setenv("GIT_ATTR_NOSYSTEM", "1", 1); - unsetenv("HOME"); - unsetenv("XDG_CONFIG_HOME"); - /* Setup the git directory and initialize the notes system. Both of these * load local configuration from the git repository, so we do them both while * the HOME variables are unset. */ setup_git_directory_gently(nongit); init_display_notes(NULL); } + static int prepare_repo_cmd(int nongit) { struct object_id oid; diff --git a/git b/git index 8104ec9..b697d92 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 8104ec994ea3849a968b4667d072fedd1e688642 +Subproject commit b697d92f56511e804b8ba20ccbe7bdc85dc66810 -- cgit v1.2.3-24-g4f1b From 8fc0c81bbbed21ee30e8a48b2ab1066a029b7b32 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 13 Jun 2019 21:41:37 +0200 Subject: git: update to v2.23.0 Update to git version v2.23.0. No changes required. Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b2bd351..96ad7cd 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.22.0 +GIT_VER = 2.23.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index b697d92..5fa0f52 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit b697d92f56511e804b8ba20ccbe7bdc85dc66810 +Subproject commit 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 -- cgit v1.2.3-24-g4f1b From bfabd4519c80f39eedba3dd5d522563899e364c9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 23 Oct 2019 23:21:54 +0200 Subject: git: update to v2.24.0 Update to git version v2.24.0. Never use get_cached_commit_buffer() directly, use repo_get_commit_buffer() instead. The latter calls the former anyway. This fixes segmentation fault when commit-graph is enabled and get_cached_commit_buffer() does not return the expected result. Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- parsing.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 96ad7cd..8a29dd9 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.23.0 +GIT_VER = 2.24.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index 5fa0f52..da72936 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 +Subproject commit da72936f544fec5a335e66432610e4cef4430991 diff --git a/parsing.c b/parsing.c index 7b3980e..93b4767 100644 --- a/parsing.c +++ b/parsing.c @@ -129,7 +129,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) { const int sha1hex_len = 40; struct commitinfo *ret; - const char *p = get_cached_commit_buffer(the_repository, commit, NULL); + const char *p = repo_get_commit_buffer(the_repository, commit, NULL); const char *t; ret = xcalloc(1, sizeof(struct commitinfo)); -- cgit v1.2.3-24-g4f1b From 583aa5d80eb01075c0f3f35df37b9144a0c9651e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 22 Nov 2019 11:09:50 +0100 Subject: ui-repolist: do not return unsigned (negative) value The function read_agefile() returns time_t, which is a signed datatime. We should not return unsigned (negative) value here. Reported-by: Johannes Stezenbach Signed-off-by: Christian Hesse --- ui-repolist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-repolist.c b/ui-repolist.c index 7cf7638..529a203 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -20,7 +20,7 @@ static time_t read_agefile(const char *path) if (readfile(path, &buf, &size)) { free(buf); - return -1; + return 0; } if (parse_date(buf, &date_buf) == 0) -- cgit v1.2.3-24-g4f1b From d8e5dd25a0d2e32ef3453a96112eea817336e4d7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 10 Dec 2019 20:40:45 +0100 Subject: git: update to v2.24.1 Update to git version v2.24.1. No changes required. Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8a29dd9..9dada6b 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.24.0 +GIT_VER = 2.24.1 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index da72936..53a06cf 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit da72936f544fec5a335e66432610e4cef4430991 +Subproject commit 53a06cf39b756eddfe4a2a34da93e3d04eb7b728 -- cgit v1.2.3-24-g4f1b From ca98c9e7bf31617efc3ff7d3575efe5bba3cde1a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 11 Dec 2019 10:55:24 +0100 Subject: tests: skip tests if strace is not functional Chances are that strace is available but not functional due to restricted permissions: strace: test_ptrace_get_syscall_info: PTRACE_TRACEME: Operation not permitted strace: ptrace(PTRACE_TRACEME, ...): Operation not permitted +++ exited with 1 +++ Just skip the tests then. Signed-off-by: Christian Hesse --- tests/t0109-gitconfig.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/t0109-gitconfig.sh b/tests/t0109-gitconfig.sh index 3ba6684..8cee75c 100755 --- a/tests/t0109-gitconfig.sh +++ b/tests/t0109-gitconfig.sh @@ -9,6 +9,12 @@ test -n "$(which strace 2>/dev/null)" || { exit } +strace true 2>/dev/null || { + skip_all='Skipping access validation tests: strace not functional' + test_done + exit +} + test_no_home_access () { non_existent_path="/path/to/some/place/that/does/not/possibly/exist" while test -d "$non_existent_path"; do -- cgit v1.2.3-24-g4f1b From bd68c98879ecc8ce9f7f6d3e01bc4ffeb9182b04 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 26 Dec 2019 00:02:23 +0100 Subject: git: update to v2.25.0 Update to git version v2.25.0. Upstream renamed 'init_display_notes()' to 'load_display_notes()' in commit 1e6ed5441a61b5085978e0429691e2e2425f6846 ("notes: rename to load_display_notes()"). Signed-off-by: Christian Hesse --- Makefile | 2 +- cgit.c | 2 +- git | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9dada6b..c970429 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.24.1 +GIT_VER = 2.25.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/cgit.c b/cgit.c index ac8c641..c4320f0 100644 --- a/cgit.c +++ b/cgit.c @@ -579,7 +579,7 @@ static void prepare_repo_env(int *nongit) * load local configuration from the git repository, so we do them both while * the HOME variables are unset. */ setup_git_directory_gently(nongit); - init_display_notes(NULL); + load_display_notes(NULL); } static int prepare_repo_cmd(int nongit) diff --git a/git b/git index 53a06cf..d0654dc 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 53a06cf39b756eddfe4a2a34da93e3d04eb7b728 +Subproject commit d0654dc308b0ba76dd8ed7bbb33c8d8f7aacd783 -- cgit v1.2.3-24-g4f1b From fa146ccabdd0de746a7076f0630af550e43d9088 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 13 Jan 2020 15:04:14 -0500 Subject: Bump version Signed-off-by: Jason A. Donenfeld --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c970429..b51de6f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all:: -CGIT_VERSION = v1.2.1 +CGIT_VERSION = v1.2.2 CGIT_SCRIPT_NAME = cgit.cgi CGIT_SCRIPT_PATH = /var/www/htdocs/cgit CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) -- cgit v1.2.3-24-g4f1b