archive: convert sha1_file_to_archive to struct object_id

Convert this function to take a pointer to struct object_id and rename it object_file_to_archive. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Mar 12, 2018 at 02:27 UTC e5ec981a4b1d5a3159945f75f600bcf3764e1874
4 files changed +12 -12
archive-tar.c
+1 -1
@@ -281,7 +281,7 @@ static int write_tar_entry(struct archiver_args *args,
281 buffer = NULL;
282 else if (S_ISLNK(mode) || S_ISREG(mode)) {
283 enum object_type type;
284 - buffer = sha1_file_to_archive(args, path, oid->hash, old_mode, &type, &size);
284 + buffer = object_file_to_archive(args, path, oid, old_mode, &type, &size);
285 if (!buffer)
286 return error("cannot read %s", oid_to_hex(oid));
287 } else {
archive-zip.c
+2 -2
@@ -344,8 +344,8 @@ static int write_zip_entry(struct archiver_args *args,
344 flags |= ZIP_STREAM;
345 out = buffer = NULL;
346 } else {
347 - buffer = sha1_file_to_archive(args, path, oid->hash, mode,
348 - &type, &size);
347 + buffer = object_file_to_archive(args, path, oid, mode,
348 + &type, &size);
349 if (!buffer)
350 return error("cannot read %s",
351 oid_to_hex(oid));
archive.c
+5 -5
@@ -63,16 +63,16 @@ static void format_subst(const struct commit *commit,
63 free(to_free);
64 }
65
66 -void *sha1_file_to_archive(const struct archiver_args *args,
67 - const char *path, const unsigned char *sha1,
68 - unsigned int mode, enum object_type *type,
69 - unsigned long *sizep)
66 +void *object_file_to_archive(const struct archiver_args *args,
67 + const char *path, const struct object_id *oid,
68 + unsigned int mode, enum object_type *type,
69 + unsigned long *sizep)
70 {
71 void *buffer;
72 const struct commit *commit = args->convert ? args->commit : NULL;
73
74 path += args->baselen;
75 - buffer = read_sha1_file(sha1, type, sizep);
75 + buffer = read_sha1_file(oid->hash, type, sizep);
76 if (buffer && S_ISREG(mode)) {
77 struct strbuf buf = STRBUF_INIT;
78 size_t size = 0;
archive.h
+4 -4
@@ -39,9 +39,9 @@ extern int write_archive_entries(struct archiver_args *args, write_archive_entry
39 extern int write_archive(int argc, const char **argv, const char *prefix, const char *name_hint, int remote);
40
41 const char *archive_format_from_filename(const char *filename);
42 -extern void *sha1_file_to_archive(const struct archiver_args *args,
43 - const char *path, const unsigned char *sha1,
44 - unsigned int mode, enum object_type *type,
45 - unsigned long *sizep);
42 +extern void *object_file_to_archive(const struct archiver_args *args,
43 + const char *path, const struct object_id *oid,
44 + unsigned int mode, enum object_type *type,
45 + unsigned long *sizep);
46
47 #endif /* ARCHIVE_H */