packfile: add repository argument to packed_object_info

Add a repository argument to allow callers of packed_object_info to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Apr 25, 2018 at 11:21 UTC 720aaa1a74a8cf5fcc35bb294013d30d218bec01
4 files changed +7 -5
builtin/pack-objects.c
+2 -1
@@ -1572,7 +1572,8 @@ static void drop_reused_delta(struct object_entry *entry)
1572
1573 oi.sizep = &entry->size;
1574 oi.typep = &entry->type;
1575 - if (packed_object_info(entry->in_pack, entry->in_pack_offset, &oi) < 0) {
1575 + if (packed_object_info(the_repository, entry->in_pack,
1576 + entry->in_pack_offset, &oi) < 0) {
1577 /*
1578 * We failed to get the info from this pack for some reason;
1579 * fall back to sha1_object_info, which may find another copy.
packfile.c
+2 -2
@@ -1333,8 +1333,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
1333 hashmap_add(&delta_base_cache, ent);
1334 }
1335
1336 -int packed_object_info(struct packed_git *p, off_t obj_offset,
1337 - struct object_info *oi)
1336 +int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,
1337 + struct object_info *oi)
1338 {
1339 struct pack_window *w_curs = NULL;
1340 unsigned long size;
packfile.h
+2 -1
@@ -125,7 +125,8 @@ extern void release_pack_memory(size_t);
125 /* global flag to enable extra checks when accessing packed objects */
126 extern int do_check_packed_object_crc;
127
128 -extern int packed_object_info(struct packed_git *pack, off_t offset, struct object_info *);
128 +#define packed_object_info(r, p, o, oi) packed_object_info_##r(p, o, oi)
129 +extern int packed_object_info_the_repository(struct packed_git *pack, off_t offset, struct object_info *);
130
131 extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);
132 extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);
sha1_file.c
+1 -1
@@ -1307,7 +1307,7 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct
1307 * information below, so return early.
1308 */
1309 return 0;
1310 - rtype = packed_object_info(e.p, e.offset, oi);
1310 + rtype = packed_object_info(the_repository, e.p, e.offset, oi);
1311 if (rtype < 0) {
1312 mark_bad_packed_object(e.p, real->hash);
1313 return oid_object_info_extended(the_repository, real, oi, 0);