archive: convert struct archiver_args to object_id
Change the commit_sha1 member to be called "commit_oid" and change it to be a pointer to struct object_id. Additionally, update some uses of GIT_SHA1_HEXSZ and hard-coded values to use the_hash_algo instead. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
87003d2c94
commit
bbf05cf70e
@ -326,14 +326,15 @@ static int write_tar_entry(struct archiver_args *args,
|
||||
|
||||
static void write_global_extended_header(struct archiver_args *args)
|
||||
{
|
||||
const unsigned char *sha1 = args->commit_sha1;
|
||||
const struct object_id *oid = args->commit_oid;
|
||||
struct strbuf ext_header = STRBUF_INIT;
|
||||
struct ustar_header header;
|
||||
unsigned int mode;
|
||||
|
||||
if (sha1)
|
||||
if (oid)
|
||||
strbuf_append_ext_header(&ext_header, "comment",
|
||||
sha1_to_hex(sha1), 40);
|
||||
oid_to_hex(oid),
|
||||
the_hash_algo->hexsz);
|
||||
if (args->time > USTAR_MAX_MTIME) {
|
||||
strbuf_append_ext_header_uint(&ext_header, "mtime",
|
||||
args->time);
|
||||
|
@ -577,7 +577,7 @@ static void write_zip64_trailer(void)
|
||||
write_or_die(1, &locator64, ZIP64_DIR_TRAILER_LOCATOR_SIZE);
|
||||
}
|
||||
|
||||
static void write_zip_trailer(const unsigned char *sha1)
|
||||
static void write_zip_trailer(const struct object_id *oid)
|
||||
{
|
||||
struct zip_dir_trailer trailer;
|
||||
int clamped = 0;
|
||||
@ -590,14 +590,14 @@ static void write_zip_trailer(const unsigned char *sha1)
|
||||
copy_le16_clamp(trailer.entries, zip_dir_entries, &clamped);
|
||||
copy_le32(trailer.size, zip_dir.len);
|
||||
copy_le32_clamp(trailer.offset, zip_offset, &clamped);
|
||||
copy_le16(trailer.comment_length, sha1 ? GIT_SHA1_HEXSZ : 0);
|
||||
copy_le16(trailer.comment_length, oid ? the_hash_algo->hexsz : 0);
|
||||
|
||||
write_or_die(1, zip_dir.buf, zip_dir.len);
|
||||
if (clamped)
|
||||
write_zip64_trailer();
|
||||
write_or_die(1, &trailer, ZIP_DIR_TRAILER_SIZE);
|
||||
if (sha1)
|
||||
write_or_die(1, sha1_to_hex(sha1), GIT_SHA1_HEXSZ);
|
||||
if (oid)
|
||||
write_or_die(1, oid_to_hex(oid), the_hash_algo->hexsz);
|
||||
}
|
||||
|
||||
static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)
|
||||
@ -635,7 +635,7 @@ static int write_zip_archive(const struct archiver *ar,
|
||||
|
||||
err = write_archive_entries(args, write_zip_entry);
|
||||
if (!err)
|
||||
write_zip_trailer(args->commit_sha1);
|
||||
write_zip_trailer(args->commit_oid);
|
||||
|
||||
strbuf_release(&zip_dir);
|
||||
|
||||
|
@ -380,7 +380,7 @@ static void parse_treeish_arg(const char **argv,
|
||||
int remote)
|
||||
{
|
||||
const char *name = argv[0];
|
||||
const unsigned char *commit_sha1;
|
||||
const struct object_id *commit_oid;
|
||||
time_t archive_time;
|
||||
struct tree *tree;
|
||||
const struct commit *commit;
|
||||
@ -402,10 +402,10 @@ static void parse_treeish_arg(const char **argv,
|
||||
|
||||
commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
|
||||
if (commit) {
|
||||
commit_sha1 = commit->object.oid.hash;
|
||||
commit_oid = &commit->object.oid;
|
||||
archive_time = commit->date;
|
||||
} else {
|
||||
commit_sha1 = NULL;
|
||||
commit_oid = NULL;
|
||||
archive_time = time(NULL);
|
||||
}
|
||||
|
||||
@ -426,7 +426,7 @@ static void parse_treeish_arg(const char **argv,
|
||||
tree = parse_tree_indirect(&tree_oid);
|
||||
}
|
||||
ar_args->tree = tree;
|
||||
ar_args->commit_sha1 = commit_sha1;
|
||||
ar_args->commit_oid = commit_oid;
|
||||
ar_args->commit = commit;
|
||||
ar_args->time = archive_time;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user