aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--cgitrc.5.txt9
m---------git0
-rwxr-xr-xtests/setup.sh2
-rwxr-xr-xtests/t0001-validate-git-versions.sh4
-rwxr-xr-xtests/t0107-snapshot.sh126
-rw-r--r--ui-blame.c6
-rw-r--r--ui-blob.c17
-rw-r--r--ui-commit.c2
-rw-r--r--ui-diff.c4
-rw-r--r--ui-log.c4
-rw-r--r--ui-plain.c7
-rw-r--r--ui-snapshot.c14
-rw-r--r--ui-tree.c8
14 files changed, 182 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index b51de6f..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)
@@ -14,7 +14,7 @@ htmldir = $(docdir)
pdfdir = $(docdir)
mandir = $(prefix)/share/man
SHA1_HEADER = <openssl/sha.h>
-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/cgitrc.5.txt b/cgitrc.5.txt
index ba77826..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" 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/git b/git
-Subproject d0654dc308b0ba76dd8ed7bbb33c8d8f7aacd78
+Subproject c522f061d551c9bb8684a7c3859b2ece4499b56
diff --git a/tests/setup.sh b/tests/setup.sh
index 7590f04..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 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/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
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh
index 6cf7aaa..c164d3e 100755
--- a/tests/t0107-snapshot.sh
+++ b/tests/t0107-snapshot.sh
@@ -38,6 +38,132 @@ 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 <tmp >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
+'
+
+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 <tmp >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
+'
+
+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 <tmp >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-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(")</td></tr>\n");
html("<tr><th>tree</th><td colspan='2' class='sha1'>");
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-snapshot.c b/ui-snapshot.c
index 9461d51..556d3ed 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -79,18 +79,32 @@ 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 };
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 },
{ ".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 },
+ { ".tar.zst", "application/x-zstd", write_tar_zstd_archive },
{ ".zip", "application/x-zip", write_zip_archive },
{ NULL }
};
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)