From 5e49023b01e5dfaacfc89199159e53c0c6e41331 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 13 Jan 2020 21:04:46 +0100 Subject: tests: allow to skip git version tests This allows to run tests non-tagged git checkout or when bisecting. Signed-off-by: Christian Hesse --- tests/t0001-validate-git-versions.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh index 3200f31..73bd32f 100755 --- a/tests/t0001-validate-git-versions.sh +++ b/tests/t0001-validate-git-versions.sh @@ -1,5 +1,9 @@ #!/bin/sh +if [ "${CGIT_TEST_NO_GIT_VERSION}" = "YesPlease" ]; then + exit 0 +fi + test_description='Check Git version is correct' CGIT_TEST_NO_CREATE_REPOS=YesPlease . ./setup.sh -- cgit v1.2.3-24-g4f1b From fde897b8171ed2e925b44ec6f69590ec07241017 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 17 Feb 2020 09:08:02 +0100 Subject: git: update to v2.25.1 Update to git version v2.25.1. No changes required. --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b51de6f..23f79cf 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.25.0 +GIT_VER = 2.25.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 d0654dc..c522f06 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit d0654dc308b0ba76dd8ed7bbb33c8d8f7aacd783 +Subproject commit c522f061d551c9bb8684a7c3859b2ece4499b56b -- cgit v1.2.3-24-g4f1b From 06671f4b2167951c6b46401b0f5ac8af4d48d50a Mon Sep 17 00:00:00 2001 From: Hanspeter Portner Date: Fri, 16 Aug 2019 23:40:19 +0200 Subject: ui-snapshot: add support for lzip compression This patch adds support for lzip [1] compressed snapshots (*.tar.lz) [1] https://www.nongnu.org/lzip/ Signed-off-by: Hanspeter Portner Signed-off-by: Jason A. Donenfeld --- cgitrc.5.txt | 4 ++-- tests/setup.sh | 2 +- tests/t0107-snapshot.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ ui-snapshot.c | 7 +++++++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/cgitrc.5.txt b/cgitrc.5.txt index ba77826..4ad3e64 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -407,8 +407,8 @@ side-by-side-diffs:: snapshots:: 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". - The special value "all" enables all snapshot formats. + more of the values "tar", "tar.gz", "tar.bz2", "tar.xz", "tar.lz" and + "zip". The special value "all" enables all snapshot formats. Default value: none. source-filter:: diff --git a/tests/setup.sh b/tests/setup.sh index 7590f04..69e47e6 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -104,7 +104,7 @@ virtual-root=/ cache-root=$PWD/cache cache-size=1021 -snapshots=tar.gz tar.bz zip +snapshots=tar.gz tar.bz tar.lz zip enable-log-filecount=1 enable-log-linecount=1 summary-log=5 diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index 6cf7aaa..a845ad9 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh @@ -38,6 +38,48 @@ test_expect_success 'verify untarred file-5' ' test_line_count = 1 master/file-5 ' +if test -n "$(which lzip 2>/dev/null)"; then + test_set_prereq LZIP +else + say 'Skipping LZIP validation tests: lzip not found' +fi + +test_expect_success LZIP 'get foo/snapshot/master.tar.lz' ' + cgit_url "foo/snapshot/master.tar.lz" >tmp +' + +test_expect_success LZIP 'check html headers' ' + head -n 1 tmp | + grep "Content-Type: application/x-lzip" && + + head -n 2 tmp | + grep "Content-Disposition: inline; filename=.master.tar.lz." +' + +test_expect_success LZIP 'strip off the header lines' ' + strip_headers master.tar.lz +' + +test_expect_success LZIP 'verify lzip format' ' + lzip --test master.tar.lz && + cp master.tar.lz /tmp/. +' + +test_expect_success LZIP 'untar' ' + rm -rf master && + tar --lzip -xf master.tar.lz +' + +test_expect_success LZIP 'count files' ' + ls master/ >output && + test_line_count = 5 output +' + +test_expect_success LZIP 'verify untarred file-5' ' + grep "^5$" master/file-5 && + test_line_count = 1 master/file-5 +' + test_expect_success 'get foo/snapshot/master.zip' ' cgit_url "foo/snapshot/master.zip" >tmp ' diff --git a/ui-snapshot.c b/ui-snapshot.c index 9461d51..92cde42 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -79,6 +79,12 @@ static int write_tar_bzip2_archive(const char *hex, const char *prefix) return write_compressed_tar_archive(hex, prefix, argv); } +static int write_tar_lzip_archive(const char *hex, const char *prefix) +{ + char *argv[] = { "lzip", NULL }; + return write_compressed_tar_archive(hex, prefix, argv); +} + static int write_tar_xz_archive(const char *hex, const char *prefix) { char *argv[] = { "xz", NULL }; @@ -90,6 +96,7 @@ const struct cgit_snapshot_format cgit_snapshot_formats[] = { { ".tar", "application/x-tar", write_tar_archive }, { ".tar.gz", "application/x-gzip", write_tar_gzip_archive }, { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive }, + { ".tar.lz", "application/x-lzip", write_tar_lzip_archive }, { ".tar.xz", "application/x-xz", write_tar_xz_archive }, { ".zip", "application/x-zip", write_zip_archive }, { NULL } -- cgit v1.2.3-24-g4f1b From cc230bf04456cc0ca82c6251b1624425eb7a7153 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2020 09:19:00 +0100 Subject: tests: add tests for xz compressed snapshots Signed-off-by: Christian Hesse --- tests/setup.sh | 2 +- tests/t0107-snapshot.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/tests/setup.sh b/tests/setup.sh index 69e47e6..334cca6 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -104,7 +104,7 @@ virtual-root=/ cache-root=$PWD/cache cache-size=1021 -snapshots=tar.gz tar.bz tar.lz zip +snapshots=tar.gz tar.bz tar.lz tar.xz zip enable-log-filecount=1 enable-log-linecount=1 summary-log=5 diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index a845ad9..84995d1 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh @@ -80,6 +80,48 @@ test_expect_success LZIP 'verify untarred file-5' ' test_line_count = 1 master/file-5 ' +if test -n "$(which xz 2>/dev/null)"; then + test_set_prereq XZ +else + say 'Skipping XZ validation tests: xz not found' +fi + +test_expect_success XZ 'get foo/snapshot/master.tar.xz' ' + cgit_url "foo/snapshot/master.tar.xz" >tmp +' + +test_expect_success XZ 'check html headers' ' + head -n 1 tmp | + grep "Content-Type: application/x-xz" && + + head -n 2 tmp | + grep "Content-Disposition: inline; filename=.master.tar.xz." +' + +test_expect_success XZ 'strip off the header lines' ' + strip_headers master.tar.xz +' + +test_expect_success XZ 'verify xz format' ' + xz --test master.tar.xz && + cp master.tar.xz /tmp/. +' + +test_expect_success XZ 'untar' ' + rm -rf master && + tar --xz -xf master.tar.xz +' + +test_expect_success XZ 'count files' ' + ls master/ >output && + test_line_count = 5 output +' + +test_expect_success XZ 'verify untarred file-5' ' + grep "^5$" master/file-5 && + test_line_count = 1 master/file-5 +' + test_expect_success 'get foo/snapshot/master.zip' ' cgit_url "foo/snapshot/master.zip" >tmp ' -- cgit v1.2.3-24-g4f1b From 892ba8c3cc0617d2087a2337d8c6e71524d7b49c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2020 09:12:21 +0100 Subject: ui-snapshot: add support for zstd compression This patch adds support for zstd [0] compressed snapshots (*.tar.zst). We enable multiple working threads (-T0), but keep default compression level. The latter can be influenced by environment variable. [0] https://www.zstd.net/ Signed-off-by: Christian Hesse --- cgitrc.5.txt | 9 ++++++--- tests/setup.sh | 2 +- tests/t0107-snapshot.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ ui-snapshot.c | 7 +++++++ 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 4ad3e64..33a6a8c 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -407,9 +407,12 @@ side-by-side-diffs:: snapshots:: 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", "tar.lz" and - "zip". The special value "all" enables all snapshot formats. - Default value: none. + more of the values "tar", "tar.gz", "tar.bz2", "tar.lz", "tar.xz", + "tar.zst" and "zip". The special value "all" enables all snapshot + formats. Default value: none. + All compressors use default settings. Some settings can be influenced + with environment variables, for example set ZSTD_CLEVEL=10 in web + server environment for higher (but slower) zstd compression. source-filter:: Specifies a command which will be invoked to format plaintext blobs diff --git a/tests/setup.sh b/tests/setup.sh index 334cca6..5879348 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -104,7 +104,7 @@ virtual-root=/ cache-root=$PWD/cache cache-size=1021 -snapshots=tar.gz tar.bz tar.lz tar.xz zip +snapshots=tar.gz tar.bz tar.lz tar.xz tar.zst zip enable-log-filecount=1 enable-log-linecount=1 summary-log=5 diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index 84995d1..c164d3e 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh @@ -122,6 +122,48 @@ test_expect_success XZ 'verify untarred file-5' ' test_line_count = 1 master/file-5 ' +if test -n "$(which zstd 2>/dev/null)"; then + test_set_prereq ZSTD +else + say 'Skipping ZSTD validation tests: zstd not found' +fi + +test_expect_success ZSTD 'get foo/snapshot/master.tar.zst' ' + cgit_url "foo/snapshot/master.tar.zst" >tmp +' + +test_expect_success ZSTD 'check html headers' ' + head -n 1 tmp | + grep "Content-Type: application/x-zstd" && + + head -n 2 tmp | + grep "Content-Disposition: inline; filename=.master.tar.zst." +' + +test_expect_success ZSTD 'strip off the header lines' ' + strip_headers master.tar.zst +' + +test_expect_success ZSTD 'verify zstd format' ' + zstd --test master.tar.zst && + cp master.tar.zst /tmp/. +' + +test_expect_success ZSTD 'untar' ' + rm -rf master && + tar --zstd -xf master.tar.zst +' + +test_expect_success ZSTD 'count files' ' + ls master/ >output && + test_line_count = 5 output +' + +test_expect_success ZSTD 'verify untarred file-5' ' + grep "^5$" master/file-5 && + test_line_count = 1 master/file-5 +' + test_expect_success 'get foo/snapshot/master.zip' ' cgit_url "foo/snapshot/master.zip" >tmp ' diff --git a/ui-snapshot.c b/ui-snapshot.c index 92cde42..556d3ed 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -91,6 +91,12 @@ static int write_tar_xz_archive(const char *hex, const char *prefix) return write_compressed_tar_archive(hex, prefix, argv); } +static int write_tar_zstd_archive(const char *hex, const char *prefix) +{ + char *argv[] = { "zstd", "-T0", NULL }; + return write_compressed_tar_archive(hex, prefix, argv); +} + const struct cgit_snapshot_format cgit_snapshot_formats[] = { /* .tar must remain the 0 index */ { ".tar", "application/x-tar", write_tar_archive }, @@ -98,6 +104,7 @@ const struct cgit_snapshot_format cgit_snapshot_formats[] = { { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive }, { ".tar.lz", "application/x-lzip", write_tar_lzip_archive }, { ".tar.xz", "application/x-xz", write_tar_xz_archive }, + { ".tar.zst", "application/x-zstd", write_tar_zstd_archive }, { ".zip", "application/x-zip", write_zip_archive }, { NULL } }; -- cgit v1.2.3-24-g4f1b From 6a8d6d4b5021af6c90ca0da806691987df449469 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 12 Mar 2020 20:52:35 -0600 Subject: global: use proper accessors for maybe_tree A previous commit changed ->tree to ->maybe_tree throughout, which may have worked at the time, but wasn't safe, because maybe_tree is loaded lazily. This manifested itself in crashes when using the "follow" log feature. The proper fix is to use the correct contextual accessors everytime we want access to maybe_tree. Thankfully, the commit.cocci script takes care of creating mostly-correct patches that we could then fix up, resulting in this commit here. Fixes: 255b78f ("git: update to v2.18.0") Reviewed-by: Christian Hesse Signed-off-by: Jason A. Donenfeld --- ui-blame.c | 6 ++++-- ui-blob.c | 17 +++++++++++------ ui-commit.c | 2 +- ui-diff.c | 4 ++-- ui-log.c | 4 ++-- ui-plain.c | 7 ++++--- ui-tree.c | 8 +++++--- 7 files changed, 29 insertions(+), 19 deletions(-) diff --git a/ui-blame.c b/ui-blame.c index 644c30a..f28eea0 100644 --- a/ui-blame.c +++ b/ui-blame.c @@ -290,8 +290,10 @@ void cgit_print_blame(void) walk_tree_ctx.match_baselen = (path_items.match) ? basedir_len(path_items.match) : -1; - read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0, - &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, + repo_get_commit_tree(the_repository, commit), + "", 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 30e2d4b..f76c641 100644 --- a/ui-blob.c +++ b/ui-blob.c @@ -56,8 +56,9 @@ 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(the_repository, lookup_commit_reference(the_repository, &oid)->maybe_tree, - "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, + repo_get_commit_tree(the_repository, lookup_commit_reference(the_repository, &oid)), + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); done: free(path_items.match); @@ -91,8 +92,10 @@ 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(the_repository, commit->maybe_tree, - "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, + repo_get_commit_tree(the_repository, commit), + "", 0, 0, &paths, walk_tree, + &walk_tree_ctx); if (!walk_tree_ctx.found_path) return -1; type = oid_object_info(the_repository, &oid, &size); @@ -148,8 +151,10 @@ 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(the_repository, commit->maybe_tree, - "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, + repo_get_commit_tree(the_repository, commit), + "", 0, 0, &paths, walk_tree, + &walk_tree_ctx); type = oid_object_info(the_repository, &oid, &size); } diff --git a/ui-commit.c b/ui-commit.c index 9a47b54..783211f 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -78,7 +78,7 @@ void cgit_print_commit(char *hex, const char *prefix) html(")\n"); html("tree"); tmp = xstrdup(hex); - cgit_tree_link(oid_to_hex(&commit->maybe_tree->object.oid), NULL, NULL, + cgit_tree_link(oid_to_hex(get_commit_tree_oid(commit)), NULL, NULL, ctx.qry.head, tmp, NULL); if (prefix) { html(" /"); diff --git a/ui-diff.c b/ui-diff.c index c60aefd..329c350 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -413,7 +413,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, "Bad commit: %s", oid_to_hex(new_rev_oid)); return; } - new_tree_oid = &commit->maybe_tree->object.oid; + new_tree_oid = get_commit_tree_oid(commit); if (old_rev) { if (get_oid(old_rev, old_rev_oid)) { @@ -434,7 +434,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, "Bad commit: %s", oid_to_hex(old_rev_oid)); return; } - old_tree_oid = &commit2->maybe_tree->object.oid; + old_tree_oid = get_commit_tree_oid(commit2); } else { old_tree_oid = NULL; } diff --git a/ui-log.c b/ui-log.c index dc5cb1e..2939c01 100644 --- a/ui-log.c +++ b/ui-log.c @@ -153,8 +153,8 @@ static int show_commit(struct commit *commit, struct rev_info *revs) rem_lines = 0; revs->diffopt.flags.recursive = 1; - diff_tree_oid(&parent->maybe_tree->object.oid, - &commit->maybe_tree->object.oid, + diff_tree_oid(get_commit_tree_oid(parent), + get_commit_tree_oid(commit), "", &revs->diffopt); diffcore_std(&revs->diffopt); diff --git a/ui-plain.c b/ui-plain.c index b73c1cf..2a7b18c 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -193,13 +193,14 @@ void cgit_print_plain(void) if (!path_items.match) { path_items.match = ""; walk_tree_ctx.match_baselen = -1; - print_dir(&commit->maybe_tree->object.oid, "", 0, ""); + print_dir(get_commit_tree_oid(commit), "", 0, ""); walk_tree_ctx.match = 2; } else walk_tree_ctx.match_baselen = basedir_len(path_items.match); - read_tree_recursive(the_repository, commit->maybe_tree, - "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, + repo_get_commit_tree(the_repository, commit), + "", 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-tree.c b/ui-tree.c index 84eb17d..1e4efb2 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -370,12 +370,14 @@ void cgit_print_tree(const char *rev, char *path) walk_tree_ctx.curr_rev = xstrdup(rev); if (path == NULL) { - ls_tree(&commit->maybe_tree->object.oid, NULL, &walk_tree_ctx); + ls_tree(get_commit_tree_oid(commit), NULL, &walk_tree_ctx); goto cleanup; } - read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0, - &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, + repo_get_commit_tree(the_repository, commit), + "", 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 55fa25adb097d2681607d8b0f51a0c393cc9af1a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 13 Mar 2020 17:49:52 -0600 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 23f79cf..49109ad 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all:: -CGIT_VERSION = v1.2.2 +CGIT_VERSION = v1.2.3 CGIT_SCRIPT_NAME = cgit.cgi CGIT_SCRIPT_PATH = /var/www/htdocs/cgit CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) -- cgit v1.2.3-24-g4f1b