object-store: allow read_object_file_extended to read from any repo

read_object_file_extended is not widely used, so migrate it all at once. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Nov 13, 2018 at 16:12 UTC a3b72c89bdd10f8b22d7dae382f0ce9833e5d179
3 files changed +10 -8
object-store.h
+3 -2
@@ -161,12 +161,13 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha
161
162 void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);
163
164 -extern void *read_object_file_extended(const struct object_id *oid,
164 +extern void *read_object_file_extended(struct repository *r,
165 + const struct object_id *oid,
166 enum object_type *type,
167 unsigned long *size, int lookup_replace);
168 static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)
169 {
169 - return read_object_file_extended(oid, type, size, 1);
170 + return read_object_file_extended(the_repository, oid, type, size, 1);
171 }
172
173 /* Read and unpack an object file into memory, write memory to an object file */
sha1-file.c
+6 -5
@@ -1403,7 +1403,8 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,
1403 * deal with them should arrange to call read_object() and give error
1404 * messages themselves.
1405 */
1406 -void *read_object_file_extended(const struct object_id *oid,
1406 +void *read_object_file_extended(struct repository *r,
1407 + const struct object_id *oid,
1408 enum object_type *type,
1409 unsigned long *size,
1410 int lookup_replace)
@@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid,
1414 const char *path;
1415 struct stat st;
1416 const struct object_id *repl = lookup_replace ?
1416 - lookup_replace_object(the_repository, oid) : oid;
1417 + lookup_replace_object(r, oid) : oid;
1418
1419 errno = 0;
1419 - data = read_object(the_repository, repl->hash, type, size);
1420 + data = read_object(r, repl->hash, type, size);
1421 if (data)
1422 return data;
1423
@@ -1428,11 +1429,11 @@ void *read_object_file_extended(const struct object_id *oid,
1429 die(_("replacement %s not found for %s"),
1430 oid_to_hex(repl), oid_to_hex(oid));
1431
1431 - if (!stat_sha1_file(the_repository, repl->hash, &st, &path))
1432 + if (!stat_sha1_file(r, repl->hash, &st, &path))
1433 die(_("loose object %s (stored in %s) is corrupt"),
1434 oid_to_hex(repl), path);
1435
1435 - if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL)
1436 + if ((p = has_packed_and_bad(r, repl->hash)) != NULL)
1437 die(_("packed object %s (stored in %s) is corrupt"),
1438 oid_to_hex(repl), p->pack_name);
1439
streaming.c
+1 -1
@@ -490,7 +490,7 @@ static struct stream_vtbl incore_vtbl = {
490
491 static open_method_decl(incore)
492 {
493 - st->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0);
493 + st->u.incore.buf = read_object_file_extended(the_repository, oid, type, &st->size, 0);
494 st->u.incore.read_ptr = 0;
495 st->vtbl = &incore_vtbl;
496