Convert remaining callers of sha1_object_info_extended to object_id

Convert the remaining caller of sha1_object_info_extended to use struct object_id. Introduce temporaries, which will be removed later, since there is a dependency loop between sha1_object_info_extended and lookup_replace_object_extended. This allows us to convert the code in a piecemeal fashion instead of all at once. 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 7984f23833d1c1b8d7d5d863ed8c42b67e0a0fba
2 files changed +15 -4
sha1_file.c
+11 -3
@@ -1231,6 +1231,9 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
1231 lookup_replace_object(sha1) :
1232 sha1;
1233 int already_retried = 0;
1234 + struct object_id realoid;
1235 +
1236 + hashcpy(realoid.hash, real);
1237
1238 if (is_null_sha1(real))
1239 return -1;
@@ -1295,7 +1298,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
1298 rtype = packed_object_info(e.p, e.offset, oi);
1299 if (rtype < 0) {
1300 mark_bad_packed_object(e.p, real);
1298 - return sha1_object_info_extended(real, oi, 0);
1301 + return sha1_object_info_extended(realoid.hash, oi, 0);
1302 } else if (oi->whence == OI_PACKED) {
1303 oi->u.packed.offset = e.offset;
1304 oi->u.packed.pack = e.p;
@@ -1323,13 +1326,16 @@ int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
1326 static void *read_object(const unsigned char *sha1, enum object_type *type,
1327 unsigned long *size)
1328 {
1329 + struct object_id oid;
1330 struct object_info oi = OBJECT_INFO_INIT;
1331 void *content;
1332 oi.typep = type;
1333 oi.sizep = size;
1334 oi.contentp = &content;
1335
1332 - if (sha1_object_info_extended(sha1, &oi, 0) < 0)
1336 + hashcpy(oid.hash, sha1);
1337 +
1338 + if (sha1_object_info_extended(oid.hash, &oi, 0) < 0)
1339 return NULL;
1340 return content;
1341 }
@@ -1723,9 +1729,11 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
1729
1730 int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
1731 {
1732 + struct object_id oid;
1733 if (!startup_info->have_repository)
1734 return 0;
1728 - return sha1_object_info_extended(sha1, NULL,
1735 + hashcpy(oid.hash, sha1);
1736 + return sha1_object_info_extended(oid.hash, NULL,
1737 flags | OBJECT_INFO_SKIP_CACHED) >= 0;
1738 }
1739
streaming.c
+4 -1
@@ -111,10 +111,13 @@ static enum input_source istream_source(const unsigned char *sha1,
111 {
112 unsigned long size;
113 int status;
114 + struct object_id oid;
115 +
116 + hashcpy(oid.hash, sha1);
117
118 oi->typep = type;
119 oi->sizep = &size;
117 - status = sha1_object_info_extended(sha1, oi, 0);
120 + status = sha1_object_info_extended(oid.hash, oi, 0);
121 if (status < 0)
122 return stream_error;
123