summaryrefslogtreecommitdiff
path: root/archive-tar.c
diff options
context:
space:
mode:
Diffstat (limited to 'archive-tar.c')
-rw-r--r--archive-tar.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/archive-tar.c b/archive-tar.c
index 5a77701a15..05d2455870 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -242,13 +242,12 @@ static void write_extended_header(struct archiver_args *args,
static int write_tar_entry(struct archiver_args *args,
const struct object_id *oid,
const char *path, size_t pathlen,
- unsigned int mode)
+ unsigned int mode,
+ void *buffer, unsigned long size)
{
struct ustar_header header;
struct strbuf ext_header = STRBUF_INIT;
- unsigned int old_mode = mode;
- unsigned long size, size_in_header;
- void *buffer;
+ unsigned long size_in_header;
int err = 0;
memset(&header, 0, sizeof(header));
@@ -282,20 +281,6 @@ static int write_tar_entry(struct archiver_args *args,
} else
memcpy(header.name, path, pathlen);
- if (S_ISREG(mode) && !args->convert &&
- oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&
- size > big_file_threshold)
- buffer = NULL;
- else if (S_ISLNK(mode) || S_ISREG(mode)) {
- enum object_type type;
- buffer = object_file_to_archive(args, path, oid, old_mode, &type, &size);
- if (!buffer)
- return error(_("cannot read %s"), oid_to_hex(oid));
- } else {
- buffer = NULL;
- size = 0;
- }
-
if (S_ISLNK(mode)) {
if (size > sizeof(header.linkname)) {
xsnprintf(header.linkname, sizeof(header.linkname),
@@ -326,7 +311,6 @@ static int write_tar_entry(struct archiver_args *args,
else
err = stream_blocked(args->repo, oid);
}
- free(buffer);
return err;
}
@@ -364,7 +348,7 @@ static struct archiver **tar_filters;
static int nr_tar_filters;
static int alloc_tar_filters;
-static struct archiver *find_tar_filter(const char *name, int len)
+static struct archiver *find_tar_filter(const char *name, size_t len)
{
int i;
for (i = 0; i < nr_tar_filters; i++) {
@@ -380,17 +364,18 @@ static int tar_filter_config(const char *var, const char *value, void *data)
struct archiver *ar;
const char *name;
const char *type;
- int namelen;
+ size_t namelen;
if (parse_config_key(var, "tar", &name, &namelen, &type) < 0 || !name)
return 0;
ar = find_tar_filter(name, namelen);
if (!ar) {
- ar = xcalloc(1, sizeof(*ar));
+ CALLOC_ARRAY(ar, 1);
ar->name = xmemdupz(name, namelen);
ar->write_archive = write_tar_filter_archive;
- ar->flags = ARCHIVER_WANT_COMPRESSION_LEVELS;
+ ar->flags = ARCHIVER_WANT_COMPRESSION_LEVELS |
+ ARCHIVER_HIGH_COMPRESSION_LEVELS;
ALLOC_GROW(tar_filters, nr_tar_filters + 1, alloc_tar_filters);
tar_filters[nr_tar_filters++] = ar;
}