- argv_array_push(&argv, "snapshot");
- argv_array_push(&argv, format);
+ strvec_push(&argv, "snapshot");
+ strvec_push(&argv, format);
if (prefix) {
struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, prefix);
strbuf_addch(&buf, '/');
if (prefix) {
struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, prefix);
strbuf_addch(&buf, '/');
- argv_array_push(&argv, "--prefix");
- argv_array_push(&argv, buf.buf);
+ strvec_push(&argv, "--prefix");
+ strvec_push(&argv, buf.buf);
/*
* Now we need to copy the pointers to arguments into a new
* structure because write_archive will rearrange its arguments
* which may result in duplicated/missing entries causing leaks
/*
* Now we need to copy the pointers to arguments into a new
* structure because write_archive will rearrange its arguments
* which may result in duplicated/missing entries causing leaks
- nargv = xmalloc(sizeof(char *) * (argv.argc + 1));
- /* argv_array guarantees a trailing NULL entry. */
- memcpy(nargv, argv.argv, sizeof(char *) * (argv.argc + 1));
+ nargv = xmalloc(sizeof(char *) * (argv.nr + 1));
+ /* strvec guarantees a trailing NULL entry. */
+ memcpy(nargv, argv.v, sizeof(char *) * (argv.nr + 1));
- result = write_archive(argv.argc, nargv, NULL, NULL, 0);
- argv_array_clear(&argv);
+ result = write_archive(argv.nr, nargv, NULL, the_repository, NULL, 0);
+ strvec_clear(&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_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);
+}
+
{ ".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", "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.xz", "application/x-xz", write_tar_xz_archive },
{ ".tar.xz", "application/x-xz", write_tar_xz_archive },
{ ".zip", "application/x-zip", write_zip_archive },
{ NULL }
};
{ ".zip", "application/x-zip", write_zip_archive },
{ NULL }
};
cgit_print_error_page(404, "Not found",
"Bad object id: %s", hex);
return 1;
}
cgit_print_error_page(404, "Not found",
"Bad object id: %s", hex);
return 1;
}
cgit_print_error_page(400, "Bad request",
"Not a commit reference: %s", hex);
return 1;
cgit_print_error_page(400, "Bad request",
"Not a commit reference: %s", hex);
return 1;
ctx.page.mimetype = xstrdup(format->mimetype);
ctx.page.filename = xstrdup(filename);
cgit_print_http_headers();
ctx.page.mimetype = xstrdup(format->mimetype);
ctx.page.filename = xstrdup(filename);
cgit_print_http_headers();
- buf = read_sha1_file(note->hash, &type, &size);
+ buf = repo_read_object_file(the_repository, note, &type, &size);
strbuf_addstr(&snapshot, filename);
strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix));
strbuf_addstr(&snapshot, filename);
strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix));
strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0);
}
strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0);
}
goto out;
strbuf_insert(&snapshot, 0, "v", 1);
goto out;
strbuf_insert(&snapshot, 0, "v", 1);
goto out;
strbuf_splice(&snapshot, 0, 1, "V", 1);
goto out;
strbuf_splice(&snapshot, 0, 1, "V", 1);
cgit_print_error_page(400, "Bad request",
"Unsupported snapshot format: %s", filename);
return;
cgit_print_error_page(400, "Bad request",
"Unsupported snapshot format: %s", filename);
return;