streaming: convert istream internals to struct object_id

Convert the various open_istream variants to take a pointer to struct object_id. Introduce a temporary, which will be removed later, to work around the fact that lookup_replace_object still returns a pointer to unsigned char. 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 575042a04f671fa1a9cf9d5c21b30a2dadbe6c7e
1 file changed +9 -6
streaming.c
+9 -6
@@ -14,7 +14,7 @@ enum input_source {
14
15 typedef int (*open_istream_fn)(struct git_istream *,
16 struct object_info *,
17 - const unsigned char *,
17 + const struct object_id *,
18 enum object_type *);
19 typedef int (*close_istream_fn)(struct git_istream *);
20 typedef ssize_t (*read_istream_fn)(struct git_istream *, char *, size_t);
@@ -27,7 +27,7 @@ struct stream_vtbl {
27 #define open_method_decl(name) \
28 int open_istream_ ##name \
29 (struct git_istream *st, struct object_info *oi, \
30 - const unsigned char *sha1, \
30 + const struct object_id *oid, \
31 enum object_type *type)
32
33 #define close_method_decl(name) \
@@ -142,13 +142,16 @@ struct git_istream *open_istream(const struct object_id *oid,
142 struct object_info oi = OBJECT_INFO_INIT;
143 const unsigned char *real = lookup_replace_object(oid->hash);
144 enum input_source src = istream_source(real, type, &oi);
145 + struct object_id realoid;
146 +
147 + hashcpy(realoid.hash, real);
148
149 if (src < 0)
150 return NULL;
151
152 st = xmalloc(sizeof(*st));
150 - if (open_istream_tbl[src](st, &oi, real, type)) {
151 - if (open_istream_incore(st, &oi, real, type)) {
153 + if (open_istream_tbl[src](st, &oi, &realoid, type)) {
154 + if (open_istream_incore(st, &oi, &realoid, type)) {
155 free(st);
156 return NULL;
157 }
@@ -338,7 +341,7 @@ static struct stream_vtbl loose_vtbl = {
341
342 static open_method_decl(loose)
343 {
341 - st->u.loose.mapped = map_sha1_file(sha1, &st->u.loose.mapsize);
344 + st->u.loose.mapped = map_sha1_file(oid->hash, &st->u.loose.mapsize);
345 if (!st->u.loose.mapped)
346 return -1;
347 if ((unpack_sha1_header(&st->z,
@@ -489,7 +492,7 @@ static struct stream_vtbl incore_vtbl = {
492
493 static open_method_decl(incore)
494 {
492 - st->u.incore.buf = read_sha1_file_extended(sha1, type, &st->size, 0);
495 + st->u.incore.buf = read_sha1_file_extended(oid->hash, type, &st->size, 0);
496 st->u.incore.read_ptr = 0;
497 st->vtbl = &incore_vtbl;
498