odb: rename `oid_object_info()`

Rename `oid_object_info()` to `odb_read_object_info()` as well as their `_extended()` variant to match other functions related to the object database and our modern coding guidelines. Introduce compatibility wrappers so that any in-flight topics will continue to compile. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jul 1, 2025 at 14:22 UTC e989dd96b8aa9b20b0e23d3fa845d0baba1b454a
48 files changed +213 -170
archive.c
+1 -1
@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
215
216 /* Stream it? */
217 if (S_ISREG(mode) && !args->convert &&
218 - oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&
218 + odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&
219 size > repo_settings_get_big_file_threshold(the_repository))
220 return write_entry(args, oid, path.buf, path.len, mode, NULL, size);
221
blame.c
+2 -2
@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,
116 unsigned short mode;
117
118 if (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&
119 - oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)
119 + odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)
120 return;
121 }
122
@@ -1245,7 +1245,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,
1245 return 0;
1246 if (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
1247 goto error_out;
1248 - if (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)
1248 + if (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)
1249 goto error_out;
1250 return 0;
1251 error_out:
builtin/blame.c
+2 -2
@@ -837,7 +837,7 @@ static int is_a_rev(const char *name)
837
838 if (repo_get_oid(the_repository, name, &oid))
839 return 0;
840 - return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
840 + return OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);
841 }
842
843 static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
@@ -848,7 +848,7 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
848 oidcpy(&oid, oid_ret);
849 while (1) {
850 struct object *obj;
851 - int kind = oid_object_info(r, &oid, NULL);
851 + int kind = odb_read_object_info(r->objects, &oid, NULL);
852 if (kind == OBJ_COMMIT) {
853 oidcpy(oid_ret, &oid);
854 return 0;
builtin/cat-file.c
+14 -12
@@ -132,7 +132,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
132 switch (opt) {
133 case 't':
134 oi.typep = &type;
135 - if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
135 + if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
136 die("git cat-file: could not get object info");
137 printf("%s\n", type_name(type));
138 ret = 0;
@@ -146,7 +146,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
146 oi.contentp = (void**)&buf;
147 }
148
149 - if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
149 + if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
150 die("git cat-file: could not get object info");
151
152 if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
@@ -180,7 +180,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
180 /* else fallthrough */
181
182 case 'p':
183 - type = oid_object_info(the_repository, &oid, NULL);
183 + type = odb_read_object_info(the_repository->objects, &oid, NULL);
184 if (type < 0)
185 die("Not a valid object name %s", obj_name);
186
@@ -217,7 +217,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
217
218 if (exp_type_id == OBJ_BLOB) {
219 struct object_id blob_oid;
220 - if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
220 + if (odb_read_object_info(the_repository->objects,
221 + &oid, NULL) == OBJ_TAG) {
222 char *buffer = repo_read_object_file(the_repository,
223 &oid,
224 &type,
@@ -235,7 +236,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
236 } else
237 oidcpy(&blob_oid, &oid);
238
238 - if (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {
239 + if (odb_read_object_info(the_repository->objects,
240 + &blob_oid, NULL) == OBJ_BLOB) {
241 ret = stream_blob(&blob_oid);
242 goto cleanup;
243 }
@@ -294,7 +296,7 @@ struct expand_data {
296
297 /*
298 * After a mark_query run, this object_info is set up to be
297 - * passed to oid_object_info_extended. It will point to the data
299 + * passed to odb_read_object_info_extended. It will point to the data
300 * elements above, so you can retrieve the response from there.
301 */
302 struct object_info info;
@@ -484,12 +486,12 @@ static void batch_object_write(const char *obj_name,
486 data->info.sizep = &data->size;
487
488 if (pack)
487 - ret = packed_object_info(the_repository, pack, offset,
488 - &data->info);
489 + ret = packed_object_info(the_repository, pack,
490 + offset, &data->info);
491 else
490 - ret = oid_object_info_extended(the_repository,
491 - &data->oid, &data->info,
492 - OBJECT_INFO_LOOKUP_REPLACE);
492 + ret = odb_read_object_info_extended(the_repository->objects,
493 + &data->oid, &data->info,
494 + OBJECT_INFO_LOOKUP_REPLACE);
495 if (ret < 0) {
496 report_object_status(opt, obj_name, &data->oid, "missing");
497 return;
@@ -872,7 +874,7 @@ static int batch_objects(struct batch_options *opt)
874
875 /*
876 * Expand once with our special mark_query flag, which will prime the
875 - * object_info to be handed to oid_object_info_extended for each
877 + * object_info to be handed to odb_read_object_info_extended for each
878 * object.
879 */
880 memset(&data, 0, sizeof(data));
builtin/describe.c
+2 -1
@@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)
552
553 if (cmit)
554 describe_commit(&oid, &sb);
555 - else if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)
555 + else if (odb_read_object_info(the_repository->objects,
556 + &oid, NULL) == OBJ_BLOB)
557 describe_blob(oid, &sb);
558 else
559 die(_("%s is neither a commit nor blob"), arg);
builtin/fast-export.c
+1 -1
@@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)
1200 if (last_idnum < mark)
1201 last_idnum = mark;
1202
1203 - type = oid_object_info(the_repository, &oid, NULL);
1203 + type = odb_read_object_info(the_repository->objects, &oid, NULL);
1204 if (type < 0)
1205 die("object not found: %s", oid_to_hex(&oid));
1206
builtin/fast-import.c
+9 -8
@@ -1756,8 +1756,8 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint
1756 struct object_entry *e;
1757 e = find_object(oid);
1758 if (!e) {
1759 - enum object_type type = oid_object_info(the_repository,
1760 - oid, NULL);
1759 + enum object_type type = odb_read_object_info(the_repository->objects,
1760 + oid, NULL);
1761 if (type < 0)
1762 die("object not found: %s", oid_to_hex(oid));
1763 e = insert_object(oid);
@@ -2416,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)
2416 enum object_type expected = S_ISDIR(mode) ?
2417 OBJ_TREE: OBJ_BLOB;
2418 enum object_type type = oe ? oe->type :
2419 - oid_object_info(the_repository, &oid,
2420 - NULL);
2419 + odb_read_object_info(the_repository->objects,
2420 + &oid, NULL);
2421 if (type < 0)
2422 die("%s not found: %s",
2423 S_ISDIR(mode) ? "Tree" : "Blob",
@@ -2553,7 +2553,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
2553 die("Not a blob (actually a %s): %s",
2554 type_name(oe->type), command_buf.buf);
2555 } else if (!is_null_oid(&oid)) {
2556 - enum object_type type = oid_object_info(the_repository, &oid,
2556 + enum object_type type = odb_read_object_info(the_repository->objects, &oid,
2557 NULL);
2558 if (type < 0)
2559 die("Blob not found: %s", command_buf.buf);
@@ -2895,7 +2895,8 @@ static void parse_new_tag(const char *arg)
2895 } else if (!repo_get_oid(the_repository, from, &oid)) {
2896 struct object_entry *oe = find_object(&oid);
2897 if (!oe) {
2898 - type = oid_object_info(the_repository, &oid, NULL);
2898 + type = odb_read_object_info(the_repository->objects,
2899 + &oid, NULL);
2900 if (type < 0)
2901 die("Not a valid object: %s", from);
2902 } else
@@ -3085,8 +3086,8 @@ static struct object_entry *dereference(struct object_entry *oe,
3086 const unsigned hexsz = the_hash_algo->hexsz;
3087
3088 if (!oe) {
3088 - enum object_type type = oid_object_info(the_repository, oid,
3089 - NULL);
3089 + enum object_type type = odb_read_object_info(the_repository->objects,
3090 + oid, NULL);
3091 if (type < 0)
3092 die("object not found: %s", oid_to_hex(oid));
3093 /* cache it! */
builtin/fsck.c
+4 -3
@@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,
71 const char *ret;
72
73 if (type == OBJ_NONE)
74 - type = oid_object_info(the_repository, oid, NULL);
74 + type = odb_read_object_info(the_repository->objects,
75 + oid, NULL);
76
77 ret = type_name(type);
78 if (!ret)
@@ -232,8 +233,8 @@ static void mark_unreachable_referents(const struct object_id *oid)
233 * (and we want to avoid parsing blobs).
234 */
235 if (obj->type == OBJ_NONE) {
235 - enum object_type type = oid_object_info(the_repository,
236 - &obj->oid, NULL);
236 + enum object_type type = odb_read_object_info(the_repository->objects,
237 + &obj->oid, NULL);
238 if (type > 0)
239 object_as_type(obj, type, 0);
240 }
builtin/gc.c
+1 -1
@@ -1080,7 +1080,7 @@ static int dfs_on_ref(const char *refname UNUSED,
1080
1081 if (!peel_iterated_oid(the_repository, oid, &peeled))
1082 oid = &peeled;
1083 - if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
1083 + if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
1084 return 0;
1085
1086 commit = lookup_commit(the_repository, oid);
builtin/grep.c
+1 -1
@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,
520 struct strbuf base = STRBUF_INIT;
521
522 obj_read_lock();
523 - object_type = oid_object_info(subrepo, oid, NULL);
523 + object_type = odb_read_object_info(subrepo->objects, oid, NULL);
524 obj_read_unlock();
525 data = read_object_with_reference(subrepo,
526 oid, OBJ_TREE,
builtin/index-pack.c
+7 -6
@@ -260,7 +260,8 @@ static unsigned check_object(struct object *obj)
260
261 if (!(obj->flags & FLAG_CHECKED)) {
262 unsigned long size;
263 - int type = oid_object_info(the_repository, &obj->oid, &size);
263 + int type = odb_read_object_info(the_repository->objects,
264 + &obj->oid, &size);
265 if (type <= 0)
266 die(_("did not receive expected object %s"),
267 oid_to_hex(&obj->oid));
@@ -908,7 +909,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
909 enum object_type has_type;
910 unsigned long has_size;
911 read_lock();
911 - has_type = oid_object_info(the_repository, oid, &has_size);
912 + has_type = odb_read_object_info(the_repository->objects, oid, &has_size);
913 if (has_type < 0)
914 die(_("cannot read existing object info %s"), oid_to_hex(oid));
915 if (has_type != type || has_size != size)
@@ -1501,9 +1502,9 @@ static void fix_unresolved_deltas(struct hashfile *f)
1502 struct oid_array to_fetch = OID_ARRAY_INIT;
1503 for (i = 0; i < nr_ref_deltas; i++) {
1504 struct ref_delta_entry *d = sorted_by_pos[i];
1504 - if (!oid_object_info_extended(the_repository, &d->oid,
1505 - NULL,
1506 - OBJECT_INFO_FOR_PREFETCH))
1505 + if (!odb_read_object_info_extended(the_repository->objects,
1506 + &d->oid, NULL,
1507 + OBJECT_INFO_FOR_PREFETCH))
1508 continue;
1509 oid_array_append(&to_fetch, &d->oid);
1510 }
@@ -1829,7 +1830,7 @@ static void repack_local_links(void)
1830 oidset_iter_init(&outgoing_links, &iter);
1831 while ((oid = oidset_iter_next(&iter))) {
1832 struct object_info info = OBJECT_INFO_INIT;
1832 - if (oid_object_info_extended(the_repository, oid, &info, 0))
1833 + if (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))
1834 /* Missing; assume it is a promisor object */
1835 continue;
1836 if (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)
builtin/ls-files.c
+1 -1
@@ -251,7 +251,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,
251 {
252 if (type == OBJ_BLOB) {
253 unsigned long size;
254 - if (oid_object_info(repo, oid, &size) < 0)
254 + if (odb_read_object_info(repo->objects, oid, &size) < 0)
255 die(_("could not get object info about '%s'"),
256 oid_to_hex(oid));
257 if (padded)
builtin/ls-tree.c
+2 -2
@@ -27,7 +27,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
27 {
28 if (type == OBJ_BLOB) {
29 unsigned long size;
30 - if (oid_object_info(the_repository, oid, &size) < 0)
30 + if (odb_read_object_info(the_repository->objects, oid, &size) < 0)
31 die(_("could not get object info about '%s'"),
32 oid_to_hex(oid));
33 if (padded)
@@ -217,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
217
218 if (type == OBJ_BLOB) {
219 unsigned long size;
220 - if (oid_object_info(the_repository, oid, &size) == OBJ_BAD)
220 + if (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)
221 xsnprintf(size_text, sizeof(size_text), "BAD");
222 else
223 xsnprintf(size_text, sizeof(size_text),
builtin/mktree.c
+4 -4
@@ -124,10 +124,10 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)
124
125 /* Check the type of object identified by oid without fetching objects */
126 oi.typep = &obj_type;
127 - if (oid_object_info_extended(the_repository, &oid, &oi,
128 - OBJECT_INFO_LOOKUP_REPLACE |
129 - OBJECT_INFO_QUICK |
130 - OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
127 + if (odb_read_object_info_extended(the_repository->objects, &oid, &oi,
128 + OBJECT_INFO_LOOKUP_REPLACE |
129 + OBJECT_INFO_QUICK |
130 + OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
131 obj_type = -1;
132
133 if (obj_type < 0) {
builtin/pack-objects.c
+16 -14
@@ -2154,10 +2154,10 @@ static void prefetch_to_pack(uint32_t object_index_start) {
2154 for (i = object_index_start; i < to_pack.nr_objects; i++) {
2155 struct object_entry *entry = to_pack.objects + i;
2156
2157 - if (!oid_object_info_extended(the_repository,
2158 - &entry->idx.oid,
2159 - NULL,
2160 - OBJECT_INFO_FOR_PREFETCH))
2157 + if (!odb_read_object_info_extended(the_repository->objects,
2158 + &entry->idx.oid,
2159 + NULL,
2160 + OBJECT_INFO_FOR_PREFETCH))
2161 continue;
2162 oid_array_append(&to_fetch, &entry->idx.oid);
2163 }
@@ -2298,19 +2298,19 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
2298
2299 /*
2300 * No choice but to fall back to the recursive delta walk
2301 - * with oid_object_info() to find about the object type
2301 + * with odb_read_object_info() to find about the object type
2302 * at this point...
2303 */
2304 give_up:
2305 unuse_pack(&w_curs);
2306 }
2307
2308 - if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
2309 - OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
2308 + if (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,
2309 + OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
2310 if (repo_has_promisor_remote(the_repository)) {
2311 prefetch_to_pack(object_index);
2312 - if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
2313 - OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
2312 + if (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,
2313 + OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
2314 type = -1;
2315 } else {
2316 type = -1;
@@ -2384,12 +2384,13 @@ static void drop_reused_delta(struct object_entry *entry)
2384 if (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
2385 /*
2386 * We failed to get the info from this pack for some reason;
2387 - * fall back to oid_object_info, which may find another copy.
2387 + * fall back to odb_read_object_info, which may find another copy.
2388 * And if that fails, the error will be recorded in oe_type(entry)
2389 * and dealt with in prepare_pack().
2390 */
2391 oe_set_type(entry,
2392 - oid_object_info(the_repository, &entry->idx.oid, &size));
2392 + odb_read_object_info(the_repository->objects,
2393 + &entry->idx.oid, &size));
2394 } else {
2395 oe_set_type(entry, type);
2396 }
@@ -2677,7 +2678,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
2678
2679 if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
2680 packing_data_lock(&to_pack);
2680 - if (oid_object_info(the_repository, &e->idx.oid, &size) < 0)
2681 + if (odb_read_object_info(the_repository->objects,
2682 + &e->idx.oid, &size) < 0)
2683 die(_("unable to get size of %s"),
2684 oid_to_hex(&e->idx.oid));
2685 packing_data_unlock(&to_pack);
@@ -4063,7 +4065,7 @@ static void add_objects_in_unpacked_packs(void)
4065 static int add_loose_object(const struct object_id *oid, const char *path,
4066 void *data UNUSED)
4067 {
4066 - enum object_type type = oid_object_info(the_repository, oid, NULL);
4068 + enum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);
4069
4070 if (type < 0) {
4071 warning(_("loose object at %s could not be examined"), path);
@@ -4449,7 +4451,7 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED,
4451 static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
4452 {
4453 struct object_info info = OBJECT_INFO_INIT;
4452 - if (oid_object_info_extended(the_repository, &obj->oid, &info, 0))
4454 + if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
4455 BUG("should_include_obj should only be called on existing objects");
4456 return info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;
4457 }
builtin/prune.c
+2 -2
@@ -99,8 +99,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
99 if (st.st_mtime > expire)
100 return 0;
101 if (show_only || verbose) {
102 - enum object_type type = oid_object_info(the_repository, oid,
103 - NULL);
102 + enum object_type type = odb_read_object_info(the_repository->objects,
103 + oid, NULL);
104 printf("%s %s\n", oid_to_hex(oid),
105 (type > 0) ? type_name(type) : "unknown");
106 }
builtin/repack.c
+1 -1
@@ -707,7 +707,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,
707 if (oidset_insert(&data->seen, oid))
708 return 0; /* already seen */
709
710 - if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
710 + if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
711 return 0;
712
713 fprintf(data->f->fp, "%s%s\n", data->preferred ? "+" : "",
builtin/replace.c
+5 -5
@@ -65,8 +65,8 @@ static int show_reference(const char *refname,
65 if (repo_get_oid(data->repo, refname, &object))
66 return error(_("failed to resolve '%s' as a valid ref"), refname);
67
68 - obj_type = oid_object_info(data->repo, &object, NULL);
69 - repl_type = oid_object_info(data->repo, oid, NULL);
68 + obj_type = odb_read_object_info(data->repo->objects, &object, NULL);
69 + repl_type = odb_read_object_info(data->repo->objects, oid, NULL);
70
71 printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
72 oid_to_hex(oid), type_name(repl_type));
@@ -185,8 +185,8 @@ static int replace_object_oid(const char *object_ref,
185 struct strbuf err = STRBUF_INIT;
186 int res = 0;
187
188 - obj_type = oid_object_info(the_repository, object, NULL);
189 - repl_type = oid_object_info(the_repository, repl, NULL);
188 + obj_type = odb_read_object_info(the_repository->objects, object, NULL);
189 + repl_type = odb_read_object_info(the_repository->objects, repl, NULL);
190 if (!force && obj_type != repl_type)
191 return error(_("Objects must be of the same type.\n"
192 "'%s' points to a replaced object of type '%s'\n"
@@ -334,7 +334,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
334 if (repo_get_oid(the_repository, object_ref, &old_oid) < 0)
335 return error(_("not a valid object name: '%s'"), object_ref);
336
337 - type = oid_object_info(the_repository, &old_oid, NULL);
337 + type = odb_read_object_info(the_repository->objects, &old_oid, NULL);
338 if (type < 0)
339 return error(_("unable to get object type for %s"),
340 oid_to_hex(&old_oid));
builtin/rev-list.c
+4 -2
@@ -110,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)
110 off_t size;
111 struct object_info oi = OBJECT_INFO_INIT;
112 oi.disk_sizep = &size;
113 - if (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)
113 + if (odb_read_object_info_extended(the_repository->objects,
114 + &obj->oid, &oi, 0) < 0)
115 die(_("unable to get disk usage of %s"), oid_to_hex(&obj->oid));
116 return size;
117 }
@@ -346,7 +347,8 @@ static void show_commit(struct commit *commit, void *data)
347 static int finish_object(struct object *obj, const char *name, void *cb_data)
348 {
349 struct rev_list_info *info = cb_data;
349 - if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {
350 + if (odb_read_object_info_extended(the_repository->objects,
351 + &obj->oid, NULL, 0) < 0) {
352 finish_object__ma(obj, name);
353 return 1;
354 }
builtin/tag.c
+2 -2
@@ -304,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,
304 struct strbuf header = STRBUF_INIT;
305 int should_edit;
306
307 - type = oid_object_info(the_repository, object, NULL);
307 + type = odb_read_object_info(the_repository->objects, object, NULL);
308 if (type <= OBJ_NONE)
309 die(_("bad object type."));
310
@@ -401,7 +401,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
401 }
402
403 strbuf_addstr(sb, " (");
404 - type = oid_object_info(the_repository, oid, NULL);
404 + type = odb_read_object_info(the_repository->objects, oid, NULL);
405 switch (type) {
406 default:
407 strbuf_addstr(sb, "object of unknown type");
builtin/unpack-objects.c
+1 -1
@@ -232,7 +232,7 @@ static int check_object(struct object *obj, enum object_type type,
232
233 if (!(obj->flags & FLAG_OPEN)) {
234 unsigned long size;
235 - int type = oid_object_info(the_repository, &obj->oid, &size);
235 + int type = odb_read_object_info(the_repository->objects, &obj->oid, &size);
236 if (type != obj->type || type <= 0)
237 die("object of unexpected type");
238 obj->flags |= FLAG_WRITTEN;
commit-graph.c
+1 -1
@@ -1862,7 +1862,7 @@ static int add_ref_to_set(const char *refname UNUSED,
1862
1863 if (!peel_iterated_oid(the_repository, oid, &peeled))
1864 oid = &peeled;
1865 - if (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)
1865 + if (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT)
1866 oidset_insert(data->commits, oid);
1867
1868 display_progress(data->progress, oidset_size(data->commits));
commit.c
+2 -1
@@ -585,7 +585,8 @@ int repo_parse_commit_internal(struct repository *r,
585 return 0;
586 }
587
588 - if (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)
588 + if (odb_read_object_info_extended(r->objects, &item->object.oid,
589 + &oi, flags) < 0)
590 return quiet_on_missing ? -1 :
591 error("Could not read %s",
592 oid_to_hex(&item->object.oid));
diff.c
+9 -9
@@ -4230,14 +4230,14 @@ int diff_populate_filespec(struct repository *r,
4230 info.contentp = &s->data;
4231
4232 if (options && options->missing_object_cb) {
4233 - if (!oid_object_info_extended(r, &s->oid, &info,
4234 - OBJECT_INFO_LOOKUP_REPLACE |
4235 - OBJECT_INFO_SKIP_FETCH_OBJECT))
4233 + if (!odb_read_object_info_extended(r->objects, &s->oid, &info,
4234 + OBJECT_INFO_LOOKUP_REPLACE |
4235 + OBJECT_INFO_SKIP_FETCH_OBJECT))
4236 goto object_read;
4237 options->missing_object_cb(options->missing_object_data);
4238 }
4239 - if (oid_object_info_extended(r, &s->oid, &info,
4240 - OBJECT_INFO_LOOKUP_REPLACE))
4239 + if (odb_read_object_info_extended(r->objects, &s->oid, &info,
4240 + OBJECT_INFO_LOOKUP_REPLACE))
4241 die("unable to read %s", oid_to_hex(&s->oid));
4242
4243 object_read:
@@ -4252,8 +4252,8 @@ object_read:
4252 }
4253 if (!info.contentp) {
4254 info.contentp = &s->data;
4255 - if (oid_object_info_extended(r, &s->oid, &info,
4256 - OBJECT_INFO_LOOKUP_REPLACE))
4255 + if (odb_read_object_info_extended(r->objects, &s->oid, &info,
4256 + OBJECT_INFO_LOOKUP_REPLACE))
4257 die("unable to read %s", oid_to_hex(&s->oid));
4258 }
4259 s->should_free = 1;
@@ -7019,8 +7019,8 @@ void diff_add_if_missing(struct repository *r,
7019 {
7020 if (filespec && filespec->oid_valid &&
7021 !S_ISGITLINK(filespec->mode) &&
7022 - oid_object_info_extended(r, &filespec->oid, NULL,
7023 - OBJECT_INFO_FOR_PREFETCH))
7022 + odb_read_object_info_extended(r->objects, &filespec->oid, NULL,
7023 + OBJECT_INFO_FOR_PREFETCH))
7024 oid_array_append(to_fetch, &filespec->oid);
7025 }
7026
fetch-pack.c
+2 -2
@@ -149,8 +149,8 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
149 }
150
151 while (1) {
152 - if (oid_object_info_extended(the_repository, oid, &info,
153 - OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
152 + if (odb_read_object_info_extended(the_repository->objects, oid, &info,
153 + OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
154 return NULL;
155 if (type == OBJ_TAG) {
156 struct tag *tag = (struct tag *)
list-objects-filter.c
+1 -1
@@ -310,7 +310,7 @@ static enum list_objects_filter_result filter_blobs_limit(
310 assert(obj->type == OBJ_BLOB);
311 assert((obj->flags & SEEN) == 0);
312
313 - t = oid_object_info(r, &obj->oid, &object_length);
313 + t = odb_read_object_info(r->objects, &obj->oid, &object_length);
314 if (t != OBJ_BLOB) { /* probably OBJ_NONE */
315 /*
316 * We DO NOT have the blob locally, so we cannot
log-tree.c
+1 -1
@@ -176,7 +176,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,
176 return 0;
177 }
178
179 - objtype = oid_object_info(the_repository, oid, NULL);
179 + objtype = odb_read_object_info(the_repository->objects, oid, NULL);
180 if (objtype < 0)
181 return 0;
182 obj = lookup_object_by_type(the_repository, oid, objtype);
merge-ort.c
+2 -2
@@ -4385,8 +4385,8 @@ static void prefetch_for_content_merges(struct merge_options *opt,
4385
4386 if ((ci->filemask & side_mask) &&
4387 S_ISREG(vi->mode) &&
4388 - oid_object_info_extended(opt->repo, &vi->oid, NULL,
4389 - OBJECT_INFO_FOR_PREFETCH))
4388 + odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,
4389 + OBJECT_INFO_FOR_PREFETCH))
4390 oid_array_append(&to_fetch, &vi->oid);
4391 }
4392 }
object-file.c
+1 -1
@@ -1108,7 +1108,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
1108 oi.typep = &type;
1109 oi.sizep = &len;
1110 oi.contentp = &buf;
1111 - if (oid_object_info_extended(the_repository, oid, &oi, 0))
1111 + if (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0))
1112 return error(_("cannot read object for %s"), oid_to_hex(oid));
1113 if (compat) {
1114 if (repo_oid_to_algop(repo, oid, compat, &compat_oid))
object-file.h
+1 -1
@@ -8,7 +8,7 @@
8 struct index_state;
9
10 /*
11 - * Set this to 0 to prevent oid_object_info_extended() from fetching missing
11 + * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing
12 * blobs. This has a difference only if extensions.partialClone is set.
13 *
14 * Its default value is 1.
object-name.c
+8 -8
@@ -251,7 +251,7 @@ static int disambiguate_commit_only(struct repository *r,
251 const struct object_id *oid,
252 void *cb_data UNUSED)
253 {
254 - int kind = oid_object_info(r, oid, NULL);
254 + int kind = odb_read_object_info(r->objects, oid, NULL);
255 return kind == OBJ_COMMIT;
256 }
257
@@ -262,7 +262,7 @@ static int disambiguate_committish_only(struct repository *r,
262 struct object *obj;
263 int kind;
264
265 - kind = oid_object_info(r, oid, NULL);
265 + kind = odb_read_object_info(r->objects, oid, NULL);
266 if (kind == OBJ_COMMIT)
267 return 1;
268 if (kind != OBJ_TAG)
@@ -279,7 +279,7 @@ static int disambiguate_tree_only(struct repository *r,
279 const struct object_id *oid,
280 void *cb_data UNUSED)
281 {
282 - int kind = oid_object_info(r, oid, NULL);
282 + int kind = odb_read_object_info(r->objects, oid, NULL);
283 return kind == OBJ_TREE;
284 }
285
@@ -290,7 +290,7 @@ static int disambiguate_treeish_only(struct repository *r,
290 struct object *obj;
291 int kind;
292
293 - kind = oid_object_info(r, oid, NULL);
293 + kind = odb_read_object_info(r->objects, oid, NULL);
294 if (kind == OBJ_TREE || kind == OBJ_COMMIT)
295 return 1;
296 if (kind != OBJ_TAG)
@@ -307,7 +307,7 @@ static int disambiguate_blob_only(struct repository *r,
307 const struct object_id *oid,
308 void *cb_data UNUSED)
309 {
310 - int kind = oid_object_info(r, oid, NULL);
310 + int kind = odb_read_object_info(r->objects, oid, NULL);
311 return kind == OBJ_BLOB;
312 }
313
@@ -399,7 +399,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
399 return 0;
400
401 hash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);
402 - type = oid_object_info(ds->repo, oid, NULL);
402 + type = odb_read_object_info(ds->repo->objects, oid, NULL);
403
404 if (type < 0) {
405 /*
@@ -514,8 +514,8 @@ static int sort_ambiguous(const void *va, const void *vb, void *ctx)
514 {
515 struct repository *sort_ambiguous_repo = ctx;
516 const struct object_id *a = va, *b = vb;
517 - int a_type = oid_object_info(sort_ambiguous_repo, a, NULL);
518 - int b_type = oid_object_info(sort_ambiguous_repo, b, NULL);
517 + int a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL);
518 + int b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL);
519 int a_type_sort;
520 int b_type_sort;
521
object.c
+3 -3
@@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,
214 struct object *o = lookup_unknown_object(r, name);
215
216 if (o->type == OBJ_NONE) {
217 - int type = oid_object_info(r, name, NULL);
217 + int type = odb_read_object_info(r->objects, name, NULL);
218 if (type < 0 || !object_as_type(o, type, 0))
219 return PEEL_INVALID;
220 }
@@ -315,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,
315 }
316
317 if ((!obj || obj->type == OBJ_BLOB) &&
318 - oid_object_info(r, oid, NULL) == OBJ_BLOB) {
318 + odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {
319 if (!skip_hash && stream_object_signature(r, repl) < 0) {
320 error(_("hash mismatch %s"), oid_to_hex(oid));
321 return NULL;
@@ -331,7 +331,7 @@ struct object *parse_object_with_flags(struct repository *r,
331 */
332 if (skip_hash && discard_tree &&
333 (!obj || obj->type == OBJ_TREE) &&
334 - oid_object_info(r, oid, NULL) == OBJ_TREE) {
334 + odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {
335 return &lookup_tree(r, oid)->object;
336 }
337
odb.c
+31 -29
@@ -647,7 +647,7 @@ static int register_all_submodule_sources(struct object_database *odb)
647 return ret;
648 }
649
650 -static int do_oid_object_info_extended(struct repository *r,
650 +static int do_oid_object_info_extended(struct object_database *odb,
651 const struct object_id *oid,
652 struct object_info *oi, unsigned flags)
653 {
@@ -660,7 +660,7 @@ static int do_oid_object_info_extended(struct repository *r,
660
661
662 if (flags & OBJECT_INFO_LOOKUP_REPLACE)
663 - real = lookup_replace_object(r, oid);
663 + real = lookup_replace_object(odb->repo, oid);
664
665 if (is_null_oid(real))
666 return -1;
@@ -668,7 +668,7 @@ static int do_oid_object_info_extended(struct repository *r,
668 if (!oi)
669 oi = &blank_oi;
670
671 - co = find_cached_object(r->objects, real);
671 + co = find_cached_object(odb, real);
672 if (co) {
673 if (oi->typep)
674 *(oi->typep) = co->type;
@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,
677 if (oi->disk_sizep)
678 *(oi->disk_sizep) = 0;
679 if (oi->delta_base_oid)
680 - oidclr(oi->delta_base_oid, r->hash_algo);
680 + oidclr(oi->delta_base_oid, odb->repo->hash_algo);
681 if (oi->contentp)
682 *oi->contentp = xmemdupz(co->buf, co->size);
683 oi->whence = OI_CACHED;
@@ -685,17 +685,17 @@ static int do_oid_object_info_extended(struct repository *r,
685 }
686
687 while (1) {
688 - if (find_pack_entry(r, real, &e))
688 + if (find_pack_entry(odb->repo, real, &e))
689 break;
690
691 /* Most likely it's a loose object. */
692 - if (!loose_object_info(r, real, oi, flags))
692 + if (!loose_object_info(odb->repo, real, oi, flags))
693 return 0;
694
695 /* Not a loose object; someone else may have just packed it. */
696 if (!(flags & OBJECT_INFO_QUICK)) {
697 - reprepare_packed_git(r);
698 - if (find_pack_entry(r, real, &e))
697 + reprepare_packed_git(odb->repo);
698 + if (find_pack_entry(odb->repo, real, &e))
699 break;
700 }
701
@@ -705,15 +705,15 @@ static int do_oid_object_info_extended(struct repository *r,
705 * `odb_add_submodule_source_by_path()` on that submodule's
706 * ODB). If any such ODBs exist, register them and try again.
707 */
708 - if (register_all_submodule_sources(r->objects))
708 + if (register_all_submodule_sources(odb))
709 /* We added some alternates; retry */
710 continue;
711
712 /* Check if it is a missing object */
713 - if (fetch_if_missing && repo_has_promisor_remote(r) &&
713 + if (fetch_if_missing && repo_has_promisor_remote(odb->repo) &&
714 !already_retried &&
715 !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
716 - promisor_remote_get_direct(r, real, 1);
716 + promisor_remote_get_direct(odb->repo, real, 1);
717 already_retried = 1;
718 continue;
719 }
@@ -723,7 +723,7 @@ static int do_oid_object_info_extended(struct repository *r,
723 if ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))
724 die(_("replacement %s not found for %s"),
725 oid_to_hex(real), oid_to_hex(oid));
726 - if ((p = has_packed_and_bad(r, real)))
726 + if ((p = has_packed_and_bad(odb->repo, real)))
727 die(_("packed object %s (stored in %s) is corrupt"),
728 oid_to_hex(real), p->pack_name);
729 }
@@ -736,10 +736,10 @@ static int do_oid_object_info_extended(struct repository *r,
736 * information below, so return early.
737 */
738 return 0;
739 - rtype = packed_object_info(r, e.p, e.offset, oi);
739 + rtype = packed_object_info(odb->repo, e.p, e.offset, oi);
740 if (rtype < 0) {
741 mark_bad_packed_object(e.p, real);
742 - return do_oid_object_info_extended(r, real, oi, 0);
742 + return do_oid_object_info_extended(odb, real, oi, 0);
743 } else if (oi->whence == OI_PACKED) {
744 oi->u.packed.offset = e.offset;
745 oi->u.packed.pack = e.p;
@@ -787,7 +787,7 @@ static int oid_object_info_convert(struct repository *r,
787 oi = &new_oi;
788 }
789
790 - ret = oid_object_info_extended(r, &oid, oi, flags);
790 + ret = odb_read_object_info_extended(r->objects, &oid, oi, flags);
791 if (ret)
792 return -1;
793 if (oi == input_oi)
@@ -830,33 +830,35 @@ static int oid_object_info_convert(struct repository *r,
830 return ret;
831 }
832
833 -int oid_object_info_extended(struct repository *r, const struct object_id *oid,
834 - struct object_info *oi, unsigned flags)
833 +int odb_read_object_info_extended(struct object_database *odb,
834 + const struct object_id *oid,
835 + struct object_info *oi,
836 + unsigned flags)
837 {
838 int ret;
839
838 - if (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo))
839 - return oid_object_info_convert(r, oid, oi, flags);
840 + if (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo))
841 + return oid_object_info_convert(odb->repo, oid, oi, flags);
842
843 obj_read_lock();
842 - ret = do_oid_object_info_extended(r, oid, oi, flags);
844 + ret = do_oid_object_info_extended(odb, oid, oi, flags);
845 obj_read_unlock();
846 return ret;
847 }
848
849
850 /* returns enum object_type or negative */
849 -int oid_object_info(struct repository *r,
850 - const struct object_id *oid,
851 - unsigned long *sizep)
851 +int odb_read_object_info(struct object_database *odb,
852 + const struct object_id *oid,
853 + unsigned long *sizep)
854 {
855 enum object_type type;
856 struct object_info oi = OBJECT_INFO_INIT;
857
858 oi.typep = &type;
859 oi.sizep = sizep;
858 - if (oid_object_info_extended(r, oid, &oi,
859 - OBJECT_INFO_LOOKUP_REPLACE) < 0)
860 + if (odb_read_object_info_extended(odb, oid, &oi,
861 + OBJECT_INFO_LOOKUP_REPLACE) < 0)
862 return -1;
863 return type;
864 }
@@ -887,7 +889,7 @@ int pretend_object_file(struct repository *repo,
889
890 /*
891 * This function dies on corrupt objects; the callers who want to
890 - * deal with them should arrange to call oid_object_info_extended() and give
892 + * deal with them should arrange to call odb_read_object_info_extended() and give
893 * error messages themselves.
894 */
895 void *repo_read_object_file(struct repository *r,
@@ -902,7 +904,7 @@ void *repo_read_object_file(struct repository *r,
904 oi.typep = type;
905 oi.sizep = size;
906 oi.contentp = &data;
905 - if (oid_object_info_extended(r, oid, &oi, flags))
907 + if (odb_read_object_info_extended(r->objects, oid, &oi, flags))
908 return NULL;
909
910 return data;
@@ -968,13 +970,13 @@ int has_object(struct repository *r, const struct object_id *oid,
970 if (!(flags & HAS_OBJECT_FETCH_PROMISOR))
971 object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;
972
971 - return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;
973 + return odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;
974 }
975
976 void odb_assert_oid_type(struct object_database *odb,
977 const struct object_id *oid, enum object_type expect)
978 {
977 - enum object_type type = oid_object_info(odb->repo, oid, NULL);
979 + enum object_type type = odb_read_object_info(odb, oid, NULL);
980 if (type < 0)
981 die(_("%s is not a valid object"), oid_to_hex(oid));
982 if (type != expect)
odb.h
+38 -8
@@ -265,9 +265,6 @@ void *repo_read_object_file(struct repository *r,
265 enum object_type *type,
266 unsigned long *size);
267
268 -/* Read and unpack an object file into memory, write memory to an object file */
269 -int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);
270 -
268 /*
269 * Add an object file to the in-memory object store, without writing it
270 * to disk.
@@ -336,9 +333,24 @@ struct object_info {
333 /* Die if object corruption (not just an object being missing) was detected. */
334 #define OBJECT_INFO_DIE_IF_CORRUPT 32
335
339 -int oid_object_info_extended(struct repository *r,
340 - const struct object_id *,
341 - struct object_info *, unsigned flags);
336 +/*
337 + * Read object info from the object database and populate the `object_info`
338 + * structure. Returns 0 on success, a negative error code otherwise.
339 + */
340 +int odb_read_object_info_extended(struct object_database *odb,
341 + const struct object_id *oid,
342 + struct object_info *oi,
343 + unsigned flags);
344 +
345 +/*
346 + * Read a subset of object info for the given object ID. Returns an `enum
347 + * object_type` on success, a negative error code otherwise. If successful and
348 + * `sizep` is non-NULL, then the size of the object will be written to the
349 + * pointer.
350 + */
351 +int odb_read_object_info(struct object_database *odb,
352 + const struct object_id *oid,
353 + unsigned long *sizep);
354
355 enum {
356 /* Retry packed storage after checking packed and loose storage */
@@ -360,7 +372,7 @@ void odb_assert_oid_type(struct object_database *odb,
372 /*
373 * Enabling the object read lock allows multiple threads to safely call the
374 * following functions in parallel: repo_read_object_file(),
363 - * read_object_with_reference(), oid_object_info() and oid_object_info_extended().
375 + * read_object_with_reference(), odb_read_object_info() and odb().
376 *
377 * obj_read_lock() and obj_read_unlock() may also be used to protect other
378 * section which cannot execute in parallel with object reading. Since the used
@@ -368,7 +380,7 @@ void odb_assert_oid_type(struct object_database *odb,
380 * reading functions. However, beware that in these cases zlib inflation won't
381 * be performed in parallel, losing performance.
382 *
371 - * TODO: oid_object_info_extended()'s call stack has a recursive behavior. If
383 + * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If
384 * any of its callees end up calling it, this recursive call won't benefit from
385 * parallel inflation.
386 */
@@ -416,4 +428,22 @@ void *read_object_with_reference(struct repository *r,
428 unsigned long *size,
429 struct object_id *oid_ret);
430
431 +/* Compatibility wrappers, to be removed once Git 2.51 has been released. */
432 +#include "repository.h"
433 +
434 +static inline int oid_object_info_extended(struct repository *r,
435 + const struct object_id *oid,
436 + struct object_info *oi,
437 + unsigned flags)
438 +{
439 + return odb_read_object_info_extended(r->objects, oid, oi, flags);
440 +}
441 +
442 +static inline int oid_object_info(struct repository *r,
443 + const struct object_id *oid,
444 + unsigned long *sizep)
445 +{
446 + return odb_read_object_info(r->objects, oid, sizep);
447 +}
448 +
449 #endif /* ODB_H */
pack-bitmap-write.c
+2 -2
@@ -144,8 +144,8 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,
144 break;
145
146 default:
147 - real_type = oid_object_info(writer->to_pack->repo,
148 - &entry->idx.oid, NULL);
147 + real_type = odb_read_object_info(writer->to_pack->repo->objects,
148 + &entry->idx.oid, NULL);
149 break;
150 }
151
pack-bitmap.c
+4 -4
@@ -1868,8 +1868,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
1868 size_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git);
1869 struct eindex *eindex = &bitmap_git->ext_index;
1870 struct object *obj = eindex->objects[eindex_pos];
1871 - if (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,
1872 - &oi, 0) < 0)
1871 + if (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid,
1872 + &oi, 0) < 0)
1873 die(_("unable to get size of %s"), oid_to_hex(&obj->oid));
1874 }
1875
@@ -3220,8 +3220,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)
3220 i)))
3221 continue;
3222
3223 - if (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,
3224 - &oi, 0) < 0)
3223 + if (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects,
3224 + &obj->oid, &oi, 0) < 0)
3225 die(_("unable to get disk usage of '%s'"),
3226 oid_to_hex(&obj->oid));
3227
packfile.c
+3 -2
@@ -1321,7 +1321,7 @@ static int retry_bad_packed_offset(struct repository *r,
1321 return OBJ_BAD;
1322 nth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));
1323 mark_bad_packed_object(p, &oid);
1324 - type = oid_object_info(r, &oid, NULL);
1324 + type = odb_read_object_info(r->objects, &oid, NULL);
1325 if (type <= OBJ_NONE)
1326 return OBJ_BAD;
1327 return type;
@@ -1849,7 +1849,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
1849 oi.typep = &type;
1850 oi.sizep = &base_size;
1851 oi.contentp = &base;
1852 - if (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)
1852 + if (odb_read_object_info_extended(r->objects, &base_oid,
1853 + &oi, 0) < 0)
1854 base = NULL;
1855
1856 external_base = base;
promisor-remote.c
+2 -2
@@ -245,8 +245,8 @@ static int remove_fetched_oids(struct repository *repo,
245 struct object_id *new_oids;
246
247 for (i = 0; i < oid_nr; i++)
248 - if (oid_object_info_extended(repo, &old_oids[i], NULL,
249 - OBJECT_INFO_SKIP_FETCH_OBJECT)) {
248 + if (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL,
249 + OBJECT_INFO_SKIP_FETCH_OBJECT)) {
250 remaining[i] = 1;
251 remaining_nr++;
252 }
protocol-caps.c
+1 -1
@@ -64,7 +64,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,
64 strbuf_addstr(&send_buffer, oid_str);
65
66 if (info->size) {
67 - if (oid_object_info(r, &oid, &object_size) < 0) {
67 + if (odb_read_object_info(r->objects, &oid, &object_size) < 0) {
68 strbuf_addstr(&send_buffer, " ");
69 } else {
70 strbuf_addf(&send_buffer, " %lu", object_size);
reachable.c
+1 -1
@@ -211,7 +211,7 @@ static void add_recent_object(const struct object_id *oid,
211 * later processing, and the revision machinery expects
212 * commits and tags to have been parsed.
213 */
214 - type = oid_object_info(the_repository, oid, NULL);
214 + type = odb_read_object_info(the_repository->objects, oid, NULL);
215 if (type < 0)
216 die("unable to get object info for %s", oid_to_hex(oid));
217
read-cache.c
+3 -3
@@ -3729,9 +3729,9 @@ void prefetch_cache_entries(const struct index_state *istate,
3729
3730 if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
3731 continue;
3732 - if (!oid_object_info_extended(the_repository, &ce->oid,
3733 - NULL,
3734 - OBJECT_INFO_FOR_PREFETCH))
3732 + if (!odb_read_object_info_extended(the_repository->objects,
3733 + &ce->oid, NULL,
3734 + OBJECT_INFO_FOR_PREFETCH))
3735 continue;
3736 oid_array_append(&to_fetch, &ce->oid);
3737 }
ref-filter.c
+2 -2
@@ -2302,8 +2302,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
2302 oi->info.sizep = &oi->size;
2303 oi->info.typep = &oi->type;
2304 }
2305 - if (oid_object_info_extended(the_repository, &oi->oid, &oi->info,
2306 - OBJECT_INFO_LOOKUP_REPLACE))
2305 + if (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info,
2306 + OBJECT_INFO_LOOKUP_REPLACE))
2307 return strbuf_addf_ret(err, -1, _("missing object %s for %s"),
2308 oid_to_hex(&oi->oid), ref->refname);
2309 if (oi->info.disk_sizep && oi->disk_size < 0)
remote.c
+3 -2
@@ -1182,7 +1182,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,
1182 BUG("'%s' is not a valid object, "
1183 "match_explicit_lhs() should catch this!",
1184 matched_src_name);
1185 - type = oid_object_info(the_repository, &oid, NULL);
1185 + type = odb_read_object_info(the_repository->objects, &oid, NULL);
1186 if (type == OBJ_COMMIT) {
1187 advise(_("The <src> part of the refspec is a commit object.\n"
1188 "Did you mean to create a new branch by pushing to\n"
@@ -1412,7 +1412,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1412 continue; /* not a tag */
1413 if (string_list_has_string(&dst_tag, ref->name))
1414 continue; /* they already have it */
1415 - if (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)
1415 + if (odb_read_object_info(the_repository->objects,
1416 + &ref->new_oid, NULL) != OBJ_TAG)
1417 continue; /* be conservative */
1418 item = string_list_append(&src_tag, ref->name);
1419 item->util = ref;
sequencer.c
+2 -3
@@ -5503,9 +5503,8 @@ int sequencer_pick_revisions(struct repository *r,
5503
5504 if (!repo_get_oid(r, name, &oid)) {
5505 if (!lookup_commit_reference_gently(r, &oid, 1)) {
5506 - enum object_type type = oid_object_info(r,
5507 - &oid,
5508 - NULL);
5506 + enum object_type type = odb_read_object_info(r->objects,
5507 + &oid, NULL);
5508 res = error(_("%s: can't cherry-pick a %s"),
5509 name, type_name(type));
5510 goto out;
streaming.c
+4 -4
@@ -44,7 +44,7 @@ struct git_istream {
44
45 union {
46 struct {
47 - char *buf; /* from oid_object_info_extended() */
47 + char *buf; /* from odb_read_object_info_extended() */
48 unsigned long read_ptr;
49 } incore;
50
@@ -403,8 +403,8 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,
403 oi.typep = type;
404 oi.sizep = &st->size;
405 oi.contentp = (void **)&st->u.incore.buf;
406 - return oid_object_info_extended(r, oid, &oi,
407 - OBJECT_INFO_DIE_IF_CORRUPT);
406 + return odb_read_object_info_extended(r->objects, oid, &oi,
407 + OBJECT_INFO_DIE_IF_CORRUPT);
408 }
409
410 /*****************************************************************************
@@ -422,7 +422,7 @@ static int istream_source(struct git_istream *st,
422
423 oi.typep = type;
424 oi.sizep = &size;
425 - status = oid_object_info_extended(r, oid, &oi, 0);
425 + status = odb_read_object_info_extended(r->objects, oid, &oi, 0);
426 if (status < 0)
427 return status;
428
submodule.c
+2 -3
@@ -968,7 +968,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
968 return 0;
969 }
970
971 - type = oid_object_info(&subrepo, oid, NULL);
971 + type = odb_read_object_info(subrepo.objects, oid, NULL);
972
973 switch (type) {
974 case OBJ_COMMIT:
@@ -1752,8 +1752,7 @@ static int fetch_start_failure(struct strbuf *err UNUSED,
1752 static int commit_missing_in_sub(const struct object_id *oid, void *data)
1753 {
1754 struct repository *subrepo = data;
1755 -
1756 - enum object_type type = oid_object_info(subrepo, oid, NULL);
1755 + enum object_type type = odb_read_object_info(subrepo->objects, oid, NULL);
1756
1757 return type != OBJ_COMMIT;
1758 }
t/helper/test-partial-clone.c
+1 -1
@@ -23,7 +23,7 @@ static void object_info(const char *gitdir, const char *oid_hex)
23 die("could not init repo");
24 if (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo))
25 die("could not parse oid");
26 - if (oid_object_info_extended(&r, &oid, &oi, 0))
26 + if (odb_read_object_info_extended(r.objects, &oid, &oi, 0))
27 die("could not obtain object info");
28 printf("%d\n", (int) size);
29
tag.c
+1 -1
@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
52 unsigned long size;
53 int ret;
54
55 - type = oid_object_info(the_repository, oid, NULL);
55 + type = odb_read_object_info(the_repository->objects, oid, NULL);
56 if (type != OBJ_TAG)
57 return error("%s: cannot verify a non-tag object of type %s.",
58 name_to_report ?