]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb: rename `oid_object_info()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Jun 2025 06:47:03 +0000 (08:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Jun 2025 15:52:01 +0000 (08:52 -0700)
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>
48 files changed:
archive.c
blame.c
builtin/blame.c
builtin/cat-file.c
builtin/describe.c
builtin/fast-export.c
builtin/fast-import.c
builtin/fsck.c
builtin/gc.c
builtin/grep.c
builtin/index-pack.c
builtin/ls-files.c
builtin/ls-tree.c
builtin/mktree.c
builtin/pack-objects.c
builtin/prune.c
builtin/repack.c
builtin/replace.c
builtin/rev-list.c
builtin/tag.c
builtin/unpack-objects.c
commit-graph.c
commit.c
diff.c
fetch-pack.c
list-objects-filter.c
log-tree.c
merge-ort.c
object-file.c
object-file.h
object-name.c
object.c
odb.c
odb.h
pack-bitmap-write.c
pack-bitmap.c
packfile.c
promisor-remote.c
protocol-caps.c
reachable.c
read-cache.c
ref-filter.c
remote.c
sequencer.c
streaming.c
submodule.c
t/helper/test-partial-clone.c
tag.c

index 7fa2cc2596a50e1e15e9deaa3c369ab8909d1cfb..f2511d530d585b66d3b8fe4ecec074306d2fd88c 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
 
        /* Stream it? */
        if (S_ISREG(mode) && !args->convert &&
-           oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&
+           odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&
            size > repo_settings_get_big_file_threshold(the_repository))
                return write_entry(args, oid, path.buf, path.len, mode, NULL, size);
 
diff --git a/blame.c b/blame.c
index 0ceea080a80cb22be44cf653aa6c150377eb87f5..97db3355af45941a8dfaa2add7d00b0ccda5aad6 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,
                unsigned short mode;
 
                if (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&
-                   oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)
+                   odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)
                        return;
        }
 
@@ -1245,7 +1245,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,
                return 0;
        if (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
                goto error_out;
-       if (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)
+       if (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)
                goto error_out;
        return 0;
  error_out:
index 15eda60af904e0887a8aa3c6d173b9d63aa1fb1e..91586e6852b09e88d80172178890af2a02b543b7 100644 (file)
@@ -837,7 +837,7 @@ static int is_a_rev(const char *name)
 
        if (repo_get_oid(the_repository, name, &oid))
                return 0;
-       return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
+       return OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);
 }
 
 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)
        oidcpy(&oid, oid_ret);
        while (1) {
                struct object *obj;
-               int kind = oid_object_info(r, &oid, NULL);
+               int kind = odb_read_object_info(r->objects, &oid, NULL);
                if (kind == OBJ_COMMIT) {
                        oidcpy(oid_ret, &oid);
                        return 0;
index f3a925a8183c2801311953abe61c89c262d62125..f7595fdb04e90183a8d536570a7d2e1e9aff3984 100644 (file)
@@ -132,7 +132,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
        switch (opt) {
        case 't':
                oi.typep = &type;
-               if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
+               if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
                        die("git cat-file: could not get object info");
                printf("%s\n", type_name(type));
                ret = 0;
@@ -146,7 +146,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                        oi.contentp = (void**)&buf;
                }
 
-               if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
+               if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
                        die("git cat-file: could not get object info");
 
                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)
                /* else fallthrough */
 
        case 'p':
-               type = oid_object_info(the_repository, &oid, NULL);
+               type = odb_read_object_info(the_repository->objects, &oid, NULL);
                if (type < 0)
                        die("Not a valid object name %s", obj_name);
 
@@ -217,7 +217,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
 
                if (exp_type_id == OBJ_BLOB) {
                        struct object_id blob_oid;
-                       if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
+                       if (odb_read_object_info(the_repository->objects,
+                                                &oid, NULL) == OBJ_TAG) {
                                char *buffer = repo_read_object_file(the_repository,
                                                                     &oid,
                                                                     &type,
@@ -235,7 +236,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                        } else
                                oidcpy(&blob_oid, &oid);
 
-                       if (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {
+                       if (odb_read_object_info(the_repository->objects,
+                                                &blob_oid, NULL) == OBJ_BLOB) {
                                ret = stream_blob(&blob_oid);
                                goto cleanup;
                        }
@@ -294,7 +296,7 @@ struct expand_data {
 
        /*
         * After a mark_query run, this object_info is set up to be
-        * passed to oid_object_info_extended. It will point to the data
+        * passed to odb_read_object_info_extended. It will point to the data
         * elements above, so you can retrieve the response from there.
         */
        struct object_info info;
@@ -484,12 +486,12 @@ static void batch_object_write(const char *obj_name,
                        data->info.sizep = &data->size;
 
                if (pack)
-                       ret = packed_object_info(the_repository, pack, offset,
-                                                &data->info);
+                       ret = packed_object_info(the_repository, pack,
+                                                offset, &data->info);
                else
-                       ret = oid_object_info_extended(the_repository,
-                                                      &data->oid, &data->info,
-                                                      OBJECT_INFO_LOOKUP_REPLACE);
+                       ret = odb_read_object_info_extended(the_repository->objects,
+                                                           &data->oid, &data->info,
+                                                           OBJECT_INFO_LOOKUP_REPLACE);
                if (ret < 0) {
                        report_object_status(opt, obj_name, &data->oid, "missing");
                        return;
@@ -872,7 +874,7 @@ static int batch_objects(struct batch_options *opt)
 
        /*
         * Expand once with our special mark_query flag, which will prime the
-        * object_info to be handed to oid_object_info_extended for each
+        * object_info to be handed to odb_read_object_info_extended for each
         * object.
         */
        memset(&data, 0, sizeof(data));
index 96cb68e5e5d0e7cb9e2662e04885d253d28655ec..fbf305d76244874129dcd4d130506971ff57d213 100644 (file)
@@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)
 
        if (cmit)
                describe_commit(&oid, &sb);
-       else if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)
+       else if (odb_read_object_info(the_repository->objects,
+                                     &oid, NULL) == OBJ_BLOB)
                describe_blob(oid, &sb);
        else
                die(_("%s is neither a commit nor blob"), arg);
index 0505f289a94e167e2fbdcaeb5960733a69a84e72..6c93cf0a8aa1f56786baa0ddeb0644980475f9a5 100644 (file)
@@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)
                if (last_idnum < mark)
                        last_idnum = mark;
 
-               type = oid_object_info(the_repository, &oid, NULL);
+               type = odb_read_object_info(the_repository->objects, &oid, NULL);
                if (type < 0)
                        die("object not found: %s", oid_to_hex(&oid));
 
index 413304db9b591b3160bb00ca865a16b5b47181cb..2718376f2c96def4fdc87d357271e36a2232205f 100644 (file)
@@ -1756,8 +1756,8 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint
        struct object_entry *e;
        e = find_object(oid);
        if (!e) {
-               enum object_type type = oid_object_info(the_repository,
-                                                       oid, NULL);
+               enum object_type type = odb_read_object_info(the_repository->objects,
+                                                            oid, NULL);
                if (type < 0)
                        die("object not found: %s", oid_to_hex(oid));
                e = insert_object(oid);
@@ -2416,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)
                enum object_type expected = S_ISDIR(mode) ?
                                                OBJ_TREE: OBJ_BLOB;
                enum object_type type = oe ? oe->type :
-                                       oid_object_info(the_repository, &oid,
-                                                       NULL);
+                                       odb_read_object_info(the_repository->objects,
+                                                            &oid, NULL);
                if (type < 0)
                        die("%s not found: %s",
                                        S_ISDIR(mode) ?  "Tree" : "Blob",
@@ -2553,7 +2553,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
                        die("Not a blob (actually a %s): %s",
                                type_name(oe->type), command_buf.buf);
        } else if (!is_null_oid(&oid)) {
-               enum object_type type = oid_object_info(the_repository, &oid,
+               enum object_type type = odb_read_object_info(the_repository->objects, &oid,
                                                        NULL);
                if (type < 0)
                        die("Blob not found: %s", command_buf.buf);
@@ -2895,7 +2895,8 @@ static void parse_new_tag(const char *arg)
        } else if (!repo_get_oid(the_repository, from, &oid)) {
                struct object_entry *oe = find_object(&oid);
                if (!oe) {
-                       type = oid_object_info(the_repository, &oid, NULL);
+                       type = odb_read_object_info(the_repository->objects,
+                                                   &oid, NULL);
                        if (type < 0)
                                die("Not a valid object: %s", from);
                } else
@@ -3085,8 +3086,8 @@ static struct object_entry *dereference(struct object_entry *oe,
        const unsigned hexsz = the_hash_algo->hexsz;
 
        if (!oe) {
-               enum object_type type = oid_object_info(the_repository, oid,
-                                                       NULL);
+               enum object_type type = odb_read_object_info(the_repository->objects,
+                                                            oid, NULL);
                if (type < 0)
                        die("object not found: %s", oid_to_hex(oid));
                /* cache it! */
index 014aa1344e26b4b950508b462011bebfd9b39c15..6e3465b026696af92cc66162a24859f0b5471783 100644 (file)
@@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,
        const char *ret;
 
        if (type == OBJ_NONE)
-               type = oid_object_info(the_repository, oid, NULL);
+               type = odb_read_object_info(the_repository->objects,
+                                           oid, NULL);
 
        ret = type_name(type);
        if (!ret)
@@ -232,8 +233,8 @@ static void mark_unreachable_referents(const struct object_id *oid)
         * (and we want to avoid parsing blobs).
         */
        if (obj->type == OBJ_NONE) {
-               enum object_type type = oid_object_info(the_repository,
-                                                       &obj->oid, NULL);
+               enum object_type type = odb_read_object_info(the_repository->objects,
+                                                            &obj->oid, NULL);
                if (type > 0)
                        object_as_type(obj, type, 0);
        }
index 50a09eb07e3f551512d1e3fb19db438d6b85c5c2..ff551fab439a4f39987028ff1f286a142c52f011 100644 (file)
@@ -1080,7 +1080,7 @@ static int dfs_on_ref(const char *refname UNUSED,
 
        if (!peel_iterated_oid(the_repository, oid, &peeled))
                oid = &peeled;
-       if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
+       if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
                return 0;
 
        commit = lookup_commit(the_repository, oid);
index cfcf916bce1e3e1e025d97fa03aca6888f8390d3..1435d462cd1883b1af5bfaca0b5fbd0554b5ce82 100644 (file)
@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,
                struct strbuf base = STRBUF_INIT;
 
                obj_read_lock();
-               object_type = oid_object_info(subrepo, oid, NULL);
+               object_type = odb_read_object_info(subrepo->objects, oid, NULL);
                obj_read_unlock();
                data = read_object_with_reference(subrepo,
                                                  oid, OBJ_TREE,
index 4d4d989eb1a29f2c9376692904448c0731da0ae5..d0b16908122bf05968bf98a08555acdc874969fa 100644 (file)
@@ -260,7 +260,8 @@ static unsigned check_object(struct object *obj)
 
        if (!(obj->flags & FLAG_CHECKED)) {
                unsigned long size;
-               int type = oid_object_info(the_repository, &obj->oid, &size);
+               int type = odb_read_object_info(the_repository->objects,
+                                               &obj->oid, &size);
                if (type <= 0)
                        die(_("did not receive expected object %s"),
                              oid_to_hex(&obj->oid));
@@ -908,7 +909,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
                enum object_type has_type;
                unsigned long has_size;
                read_lock();
-               has_type = oid_object_info(the_repository, oid, &has_size);
+               has_type = odb_read_object_info(the_repository->objects, oid, &has_size);
                if (has_type < 0)
                        die(_("cannot read existing object info %s"), oid_to_hex(oid));
                if (has_type != type || has_size != size)
@@ -1501,9 +1502,9 @@ static void fix_unresolved_deltas(struct hashfile *f)
                struct oid_array to_fetch = OID_ARRAY_INIT;
                for (i = 0; i < nr_ref_deltas; i++) {
                        struct ref_delta_entry *d = sorted_by_pos[i];
-                       if (!oid_object_info_extended(the_repository, &d->oid,
-                                                     NULL,
-                                                     OBJECT_INFO_FOR_PREFETCH))
+                       if (!odb_read_object_info_extended(the_repository->objects,
+                                                          &d->oid, NULL,
+                                                          OBJECT_INFO_FOR_PREFETCH))
                                continue;
                        oid_array_append(&to_fetch, &d->oid);
                }
@@ -1829,7 +1830,7 @@ static void repack_local_links(void)
        oidset_iter_init(&outgoing_links, &iter);
        while ((oid = oidset_iter_next(&iter))) {
                struct object_info info = OBJECT_INFO_INIT;
-               if (oid_object_info_extended(the_repository, oid, &info, 0))
+               if (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))
                        /* Missing; assume it is a promisor object */
                        continue;
                if (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)
index 821339b07d4f3dbbc75ce293f3e4b076502230ba..ff975e7be06045bd7412b3a306cfe8bd38c137bc 100644 (file)
@@ -251,7 +251,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,
 {
        if (type == OBJ_BLOB) {
                unsigned long size;
-               if (oid_object_info(repo, oid, &size) < 0)
+               if (odb_read_object_info(repo->objects, oid, &size) < 0)
                        die(_("could not get object info about '%s'"),
                            oid_to_hex(oid));
                if (padded)
index 62b6fd58c1655d9e307446b5390a2e3399a90678..4d616dd52827d90ab141f09d1e2ad6429fe3198b 100644 (file)
@@ -27,7 +27,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
 {
        if (type == OBJ_BLOB) {
                unsigned long size;
-               if (oid_object_info(the_repository, oid, &size) < 0)
+               if (odb_read_object_info(the_repository->objects, oid, &size) < 0)
                        die(_("could not get object info about '%s'"),
                            oid_to_hex(oid));
                if (padded)
@@ -217,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
 
        if (type == OBJ_BLOB) {
                unsigned long size;
-               if (oid_object_info(the_repository, oid, &size) == OBJ_BAD)
+               if (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)
                        xsnprintf(size_text, sizeof(size_text), "BAD");
                else
                        xsnprintf(size_text, sizeof(size_text),
index 016b0e5b2247927e48f853770eb8eb94ff8d16b3..81df7f6099fa4e4c98290402948e42398fed5dfb 100644 (file)
@@ -124,10 +124,10 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)
 
        /* Check the type of object identified by oid without fetching objects */
        oi.typep = &obj_type;
-       if (oid_object_info_extended(the_repository, &oid, &oi,
-                                    OBJECT_INFO_LOOKUP_REPLACE |
-                                    OBJECT_INFO_QUICK |
-                                    OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
+       if (odb_read_object_info_extended(the_repository->objects, &oid, &oi,
+                                         OBJECT_INFO_LOOKUP_REPLACE |
+                                         OBJECT_INFO_QUICK |
+                                         OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
                obj_type = -1;
 
        if (obj_type < 0) {
index 99b63cb0980218bb209d9b4246473fd2d286ef21..da35d684081aea0edde465eefc6e64b11ae98fd6 100644 (file)
@@ -2154,10 +2154,10 @@ static void prefetch_to_pack(uint32_t object_index_start) {
        for (i = object_index_start; i < to_pack.nr_objects; i++) {
                struct object_entry *entry = to_pack.objects + i;
 
-               if (!oid_object_info_extended(the_repository,
-                                             &entry->idx.oid,
-                                             NULL,
-                                             OBJECT_INFO_FOR_PREFETCH))
+               if (!odb_read_object_info_extended(the_repository->objects,
+                                                  &entry->idx.oid,
+                                                  NULL,
+                                                  OBJECT_INFO_FOR_PREFETCH))
                        continue;
                oid_array_append(&to_fetch, &entry->idx.oid);
        }
@@ -2298,19 +2298,19 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
 
                /*
                 * No choice but to fall back to the recursive delta walk
-                * with oid_object_info() to find about the object type
+                * with odb_read_object_info() to find about the object type
                 * at this point...
                 */
                give_up:
                unuse_pack(&w_curs);
        }
 
-       if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
-                                    OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
+       if (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,
+                                         OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
                if (repo_has_promisor_remote(the_repository)) {
                        prefetch_to_pack(object_index);
-                       if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
-                                                    OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
+                       if (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi,
+                                                         OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
                                type = -1;
                } else {
                        type = -1;
@@ -2384,12 +2384,13 @@ static void drop_reused_delta(struct object_entry *entry)
        if (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
                /*
                 * We failed to get the info from this pack for some reason;
-                * fall back to oid_object_info, which may find another copy.
+                * fall back to odb_read_object_info, which may find another copy.
                 * And if that fails, the error will be recorded in oe_type(entry)
                 * and dealt with in prepare_pack().
                 */
                oe_set_type(entry,
-                           oid_object_info(the_repository, &entry->idx.oid, &size));
+                           odb_read_object_info(the_repository->objects,
+                                                &entry->idx.oid, &size));
        } else {
                oe_set_type(entry, type);
        }
@@ -2677,7 +2678,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
 
        if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
                packing_data_lock(&to_pack);
-               if (oid_object_info(the_repository, &e->idx.oid, &size) < 0)
+               if (odb_read_object_info(the_repository->objects,
+                                        &e->idx.oid, &size) < 0)
                        die(_("unable to get size of %s"),
                            oid_to_hex(&e->idx.oid));
                packing_data_unlock(&to_pack);
@@ -4063,7 +4065,7 @@ static void add_objects_in_unpacked_packs(void)
 static int add_loose_object(const struct object_id *oid, const char *path,
                            void *data UNUSED)
 {
-       enum object_type type = oid_object_info(the_repository, oid, NULL);
+       enum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);
 
        if (type < 0) {
                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,
 static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
 {
        struct object_info info = OBJECT_INFO_INIT;
-       if (oid_object_info_extended(the_repository, &obj->oid, &info, 0))
+       if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
                BUG("should_include_obj should only be called on existing objects");
        return info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;
 }
index 7bbfb14c2bedf44e51596b5672c19b5d306ac4a1..339017c7ccf37c7e3df49643f3fdfb54a885c544 100644 (file)
@@ -99,8 +99,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
        if (st.st_mtime > expire)
                return 0;
        if (show_only || verbose) {
-               enum object_type type = oid_object_info(the_repository, oid,
-                                                       NULL);
+               enum object_type type = odb_read_object_info(the_repository->objects,
+                                                            oid, NULL);
                printf("%s %s\n", oid_to_hex(oid),
                       (type > 0) ? type_name(type) : "unknown");
        }
index 8145474cf8d98b5e561487a6f5ecb2444c4cfb7a..a89c2b704fb4553e4475b376f9686e0234d02967 100644 (file)
@@ -707,7 +707,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,
        if (oidset_insert(&data->seen, oid))
                return 0; /* already seen */
 
-       if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
+       if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
                return 0;
 
        fprintf(data->f->fp, "%s%s\n", data->preferred ? "+" : "",
index 11c7e2d4c0cbcccefb6333168ba51c7cb6da8846..5ff2ab723cbd58eca7b9b263deff156fcee38639 100644 (file)
@@ -65,8 +65,8 @@ static int show_reference(const char *refname,
                        if (repo_get_oid(data->repo, refname, &object))
                                return error(_("failed to resolve '%s' as a valid ref"), refname);
 
-                       obj_type = oid_object_info(data->repo, &object, NULL);
-                       repl_type = oid_object_info(data->repo, oid, NULL);
+                       obj_type = odb_read_object_info(data->repo->objects, &object, NULL);
+                       repl_type = odb_read_object_info(data->repo->objects, oid, NULL);
 
                        printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
                               oid_to_hex(oid), type_name(repl_type));
@@ -185,8 +185,8 @@ static int replace_object_oid(const char *object_ref,
        struct strbuf err = STRBUF_INIT;
        int res = 0;
 
-       obj_type = oid_object_info(the_repository, object, NULL);
-       repl_type = oid_object_info(the_repository, repl, NULL);
+       obj_type = odb_read_object_info(the_repository->objects, object, NULL);
+       repl_type = odb_read_object_info(the_repository->objects, repl, NULL);
        if (!force && obj_type != repl_type)
                return error(_("Objects must be of the same type.\n"
                               "'%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)
        if (repo_get_oid(the_repository, object_ref, &old_oid) < 0)
                return error(_("not a valid object name: '%s'"), object_ref);
 
-       type = oid_object_info(the_repository, &old_oid, NULL);
+       type = odb_read_object_info(the_repository->objects, &old_oid, NULL);
        if (type < 0)
                return error(_("unable to get object type for %s"),
                             oid_to_hex(&old_oid));
index 0ee37a32cb211c54a13ef56da16d9c451f8f0a59..4d0c460f1862dbc2ff46a3697a1112a690831d18 100644 (file)
@@ -110,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)
        off_t size;
        struct object_info oi = OBJECT_INFO_INIT;
        oi.disk_sizep = &size;
-       if (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)
+       if (odb_read_object_info_extended(the_repository->objects,
+                                         &obj->oid, &oi, 0) < 0)
                die(_("unable to get disk usage of %s"), oid_to_hex(&obj->oid));
        return size;
 }
@@ -346,7 +347,8 @@ static void show_commit(struct commit *commit, void *data)
 static int finish_object(struct object *obj, const char *name, void *cb_data)
 {
        struct rev_list_info *info = cb_data;
-       if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {
+       if (odb_read_object_info_extended(the_repository->objects,
+                                         &obj->oid, NULL, 0) < 0) {
                finish_object__ma(obj, name);
                return 1;
        }
index cf2ea4b4993daf1b03c1d0931afb79de8f78943f..e0b27396c6b90524ec174b872ea1b91c8aa1b973 100644 (file)
@@ -304,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,
        struct strbuf header = STRBUF_INIT;
        int should_edit;
 
-       type = oid_object_info(the_repository, object, NULL);
+       type = odb_read_object_info(the_repository->objects, object, NULL);
        if (type <= OBJ_NONE)
                die(_("bad object type."));
 
@@ -401,7 +401,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
        }
 
        strbuf_addstr(sb, " (");
-       type = oid_object_info(the_repository, oid, NULL);
+       type = odb_read_object_info(the_repository->objects, oid, NULL);
        switch (type) {
        default:
                strbuf_addstr(sb, "object of unknown type");
index 7bf395eec8461d265b0b631433604addcb4ac92f..405e78bc592387959e8fe9e890f5abf9d12189be 100644 (file)
@@ -232,7 +232,7 @@ static int check_object(struct object *obj, enum object_type type,
 
        if (!(obj->flags & FLAG_OPEN)) {
                unsigned long size;
-               int type = oid_object_info(the_repository, &obj->oid, &size);
+               int type = odb_read_object_info(the_repository->objects, &obj->oid, &size);
                if (type != obj->type || type <= 0)
                        die("object of unexpected type");
                obj->flags |= FLAG_WRITTEN;
index 59265f89385a397fde3d929d083d4b3cbe45c8bb..5f482d3377ff1b14dd36ed458b472f92d61bb833 100644 (file)
@@ -1862,7 +1862,7 @@ static int add_ref_to_set(const char *refname UNUSED,
 
        if (!peel_iterated_oid(the_repository, oid, &peeled))
                oid = &peeled;
-       if (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)
+       if (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT)
                oidset_insert(data->commits, oid);
 
        display_progress(data->progress, oidset_size(data->commits));
index aa65183d8b6dd860b393ada6451dc2a752225398..d4aa9c7a5f81a8c398c2a1970efe4084c63f3120 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -585,7 +585,8 @@ int repo_parse_commit_internal(struct repository *r,
                return 0;
        }
 
-       if (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)
+       if (odb_read_object_info_extended(r->objects, &item->object.oid,
+                                         &oi, flags) < 0)
                return quiet_on_missing ? -1 :
                        error("Could not read %s",
                             oid_to_hex(&item->object.oid));
diff --git a/diff.c b/diff.c
index 3af108115b351bbb2629abfef2fb5c541006170a..dca87e164fb61576b9a0c6a832849df8abd041c6 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4230,14 +4230,14 @@ int diff_populate_filespec(struct repository *r,
                        info.contentp = &s->data;
 
                if (options && options->missing_object_cb) {
-                       if (!oid_object_info_extended(r, &s->oid, &info,
-                                                     OBJECT_INFO_LOOKUP_REPLACE |
-                                                     OBJECT_INFO_SKIP_FETCH_OBJECT))
+                       if (!odb_read_object_info_extended(r->objects, &s->oid, &info,
+                                                          OBJECT_INFO_LOOKUP_REPLACE |
+                                                          OBJECT_INFO_SKIP_FETCH_OBJECT))
                                goto object_read;
                        options->missing_object_cb(options->missing_object_data);
                }
-               if (oid_object_info_extended(r, &s->oid, &info,
-                                            OBJECT_INFO_LOOKUP_REPLACE))
+               if (odb_read_object_info_extended(r->objects, &s->oid, &info,
+                                                 OBJECT_INFO_LOOKUP_REPLACE))
                        die("unable to read %s", oid_to_hex(&s->oid));
 
 object_read:
@@ -4252,8 +4252,8 @@ object_read:
                }
                if (!info.contentp) {
                        info.contentp = &s->data;
-                       if (oid_object_info_extended(r, &s->oid, &info,
-                                                    OBJECT_INFO_LOOKUP_REPLACE))
+                       if (odb_read_object_info_extended(r->objects, &s->oid, &info,
+                                                         OBJECT_INFO_LOOKUP_REPLACE))
                                die("unable to read %s", oid_to_hex(&s->oid));
                }
                s->should_free = 1;
@@ -7019,8 +7019,8 @@ void diff_add_if_missing(struct repository *r,
 {
        if (filespec && filespec->oid_valid &&
            !S_ISGITLINK(filespec->mode) &&
-           oid_object_info_extended(r, &filespec->oid, NULL,
-                                    OBJECT_INFO_FOR_PREFETCH))
+           odb_read_object_info_extended(r->objects, &filespec->oid, NULL,
+                                         OBJECT_INFO_FOR_PREFETCH))
                oid_array_append(to_fetch, &filespec->oid);
 }
 
index 47fa7fa4c492cbcba7232cc03bd45148b7a9b962..0f5de1c94d147876b1460c05605d5913acc9f8f5 100644 (file)
@@ -149,8 +149,8 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
        }
 
        while (1) {
-               if (oid_object_info_extended(the_repository, oid, &info,
-                                            OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
+               if (odb_read_object_info_extended(the_repository->objects, oid, &info,
+                                                 OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
                        return NULL;
                if (type == OBJ_TAG) {
                        struct tag *tag = (struct tag *)
index 80fe48a52c8a7c4c4035490d84774e357161ee0c..7ecd4d9ef50a8ed802616a73b9a933b585c61272 100644 (file)
@@ -310,7 +310,7 @@ static enum list_objects_filter_result filter_blobs_limit(
                assert(obj->type == OBJ_BLOB);
                assert((obj->flags & SEEN) == 0);
 
-               t = oid_object_info(r, &obj->oid, &object_length);
+               t = odb_read_object_info(r->objects, &obj->oid, &object_length);
                if (t != OBJ_BLOB) { /* probably OBJ_NONE */
                        /*
                         * We DO NOT have the blob locally, so we cannot
index 1d05dc1c7010d58039893dea81ffc0346d66968e..233bf9f227c61b09bbec910d594f7bcb3c9ff02d 100644 (file)
@@ -176,7 +176,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,
                return 0;
        }
 
-       objtype = oid_object_info(the_repository, oid, NULL);
+       objtype = odb_read_object_info(the_repository->objects, oid, NULL);
        if (objtype < 0)
                return 0;
        obj = lookup_object_by_type(the_repository, oid, objtype);
index 9f693ab1d36c9abdc89bfbce9f4d14ddf2f04154..f29417040c1cd9824ebdcc48cdc2bedde57d577c 100644 (file)
@@ -4385,8 +4385,8 @@ static void prefetch_for_content_merges(struct merge_options *opt,
 
                        if ((ci->filemask & side_mask) &&
                            S_ISREG(vi->mode) &&
-                           oid_object_info_extended(opt->repo, &vi->oid, NULL,
-                                                    OBJECT_INFO_FOR_PREFETCH))
+                           odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL,
+                                                         OBJECT_INFO_FOR_PREFETCH))
                                oid_array_append(&to_fetch, &vi->oid);
                }
        }
index 04da19a1a3bd7765d613c08c997cc8c4e2934bf7..3d674d1093e449016921248f78cdccff313fe350 100644 (file)
@@ -1108,7 +1108,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
        oi.typep = &type;
        oi.sizep = &len;
        oi.contentp = &buf;
-       if (oid_object_info_extended(the_repository, oid, &oi, 0))
+       if (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0))
                return error(_("cannot read object for %s"), oid_to_hex(oid));
        if (compat) {
                if (repo_oid_to_algop(repo, oid, compat, &compat_oid))
index 5066638f8eccd0aa0f443ee587d11c6bd1a36473..67b4ffc480833b0dbf1ac77760621d1b5661b740 100644 (file)
@@ -8,7 +8,7 @@
 struct index_state;
 
 /*
- * Set this to 0 to prevent oid_object_info_extended() from fetching missing
+ * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing
  * blobs. This has a difference only if extensions.partialClone is set.
  *
  * Its default value is 1.
index 381536e900e3650c371055613901ab7b86fb5929..e225eb602cfa60cc8659328bb57857fa0f48dbb1 100644 (file)
@@ -251,7 +251,7 @@ static int disambiguate_commit_only(struct repository *r,
                                    const struct object_id *oid,
                                    void *cb_data UNUSED)
 {
-       int kind = oid_object_info(r, oid, NULL);
+       int kind = odb_read_object_info(r->objects, oid, NULL);
        return kind == OBJ_COMMIT;
 }
 
@@ -262,7 +262,7 @@ static int disambiguate_committish_only(struct repository *r,
        struct object *obj;
        int kind;
 
-       kind = oid_object_info(r, oid, NULL);
+       kind = odb_read_object_info(r->objects, oid, NULL);
        if (kind == OBJ_COMMIT)
                return 1;
        if (kind != OBJ_TAG)
@@ -279,7 +279,7 @@ static int disambiguate_tree_only(struct repository *r,
                                  const struct object_id *oid,
                                  void *cb_data UNUSED)
 {
-       int kind = oid_object_info(r, oid, NULL);
+       int kind = odb_read_object_info(r->objects, oid, NULL);
        return kind == OBJ_TREE;
 }
 
@@ -290,7 +290,7 @@ static int disambiguate_treeish_only(struct repository *r,
        struct object *obj;
        int kind;
 
-       kind = oid_object_info(r, oid, NULL);
+       kind = odb_read_object_info(r->objects, oid, NULL);
        if (kind == OBJ_TREE || kind == OBJ_COMMIT)
                return 1;
        if (kind != OBJ_TAG)
@@ -307,7 +307,7 @@ static int disambiguate_blob_only(struct repository *r,
                                  const struct object_id *oid,
                                  void *cb_data UNUSED)
 {
-       int kind = oid_object_info(r, oid, NULL);
+       int kind = odb_read_object_info(r->objects, oid, NULL);
        return kind == OBJ_BLOB;
 }
 
@@ -399,7 +399,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
                return 0;
 
        hash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);
-       type = oid_object_info(ds->repo, oid, NULL);
+       type = odb_read_object_info(ds->repo->objects, oid, NULL);
 
        if (type < 0) {
                /*
@@ -514,8 +514,8 @@ static int sort_ambiguous(const void *va, const void *vb, void *ctx)
 {
        struct repository *sort_ambiguous_repo = ctx;
        const struct object_id *a = va, *b = vb;
-       int a_type = oid_object_info(sort_ambiguous_repo, a, NULL);
-       int b_type = oid_object_info(sort_ambiguous_repo, b, NULL);
+       int a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL);
+       int b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL);
        int a_type_sort;
        int b_type_sort;
 
index 3b15469139d2ef9b41fa659d9ae2e95314fe5496..868d89eed42da1a856d2c65e700f98f915403afc 100644 (file)
--- a/object.c
+++ b/object.c
@@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,
        struct object *o = lookup_unknown_object(r, name);
 
        if (o->type == OBJ_NONE) {
-               int type = oid_object_info(r, name, NULL);
+               int type = odb_read_object_info(r->objects, name, NULL);
                if (type < 0 || !object_as_type(o, type, 0))
                        return PEEL_INVALID;
        }
@@ -315,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,
        }
 
        if ((!obj || obj->type == OBJ_BLOB) &&
-           oid_object_info(r, oid, NULL) == OBJ_BLOB) {
+           odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {
                if (!skip_hash && stream_object_signature(r, repl) < 0) {
                        error(_("hash mismatch %s"), oid_to_hex(oid));
                        return NULL;
@@ -331,7 +331,7 @@ struct object *parse_object_with_flags(struct repository *r,
         */
        if (skip_hash && discard_tree &&
            (!obj || obj->type == OBJ_TREE) &&
-           oid_object_info(r, oid, NULL) == OBJ_TREE) {
+           odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {
                return &lookup_tree(r, oid)->object;
        }
 
diff --git a/odb.c b/odb.c
index d6ca5b92ab8334256ca71052c9b20d7601d29dbb..c3fe79171619dc13d29441c397a00123b617bea5 100644 (file)
--- a/odb.c
+++ b/odb.c
@@ -647,7 +647,7 @@ static int register_all_submodule_sources(struct object_database *odb)
        return ret;
 }
 
-static int do_oid_object_info_extended(struct repository *r,
+static int do_oid_object_info_extended(struct object_database *odb,
                                       const struct object_id *oid,
                                       struct object_info *oi, unsigned flags)
 {
@@ -660,7 +660,7 @@ static int do_oid_object_info_extended(struct repository *r,
 
 
        if (flags & OBJECT_INFO_LOOKUP_REPLACE)
-               real = lookup_replace_object(r, oid);
+               real = lookup_replace_object(odb->repo, oid);
 
        if (is_null_oid(real))
                return -1;
@@ -668,7 +668,7 @@ static int do_oid_object_info_extended(struct repository *r,
        if (!oi)
                oi = &blank_oi;
 
-       co = find_cached_object(r->objects, real);
+       co = find_cached_object(odb, real);
        if (co) {
                if (oi->typep)
                        *(oi->typep) = co->type;
@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,
                if (oi->disk_sizep)
                        *(oi->disk_sizep) = 0;
                if (oi->delta_base_oid)
-                       oidclr(oi->delta_base_oid, r->hash_algo);
+                       oidclr(oi->delta_base_oid, odb->repo->hash_algo);
                if (oi->contentp)
                        *oi->contentp = xmemdupz(co->buf, co->size);
                oi->whence = OI_CACHED;
@@ -685,17 +685,17 @@ static int do_oid_object_info_extended(struct repository *r,
        }
 
        while (1) {
-               if (find_pack_entry(r, real, &e))
+               if (find_pack_entry(odb->repo, real, &e))
                        break;
 
                /* Most likely it's a loose object. */
-               if (!loose_object_info(r, real, oi, flags))
+               if (!loose_object_info(odb->repo, real, oi, flags))
                        return 0;
 
                /* Not a loose object; someone else may have just packed it. */
                if (!(flags & OBJECT_INFO_QUICK)) {
-                       reprepare_packed_git(r);
-                       if (find_pack_entry(r, real, &e))
+                       reprepare_packed_git(odb->repo);
+                       if (find_pack_entry(odb->repo, real, &e))
                                break;
                }
 
@@ -705,15 +705,15 @@ static int do_oid_object_info_extended(struct repository *r,
                 * `odb_add_submodule_source_by_path()` on that submodule's
                 * ODB). If any such ODBs exist, register them and try again.
                 */
-               if (register_all_submodule_sources(r->objects))
+               if (register_all_submodule_sources(odb))
                        /* We added some alternates; retry */
                        continue;
 
                /* Check if it is a missing object */
-               if (fetch_if_missing && repo_has_promisor_remote(r) &&
+               if (fetch_if_missing && repo_has_promisor_remote(odb->repo) &&
                    !already_retried &&
                    !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
-                       promisor_remote_get_direct(r, real, 1);
+                       promisor_remote_get_direct(odb->repo, real, 1);
                        already_retried = 1;
                        continue;
                }
@@ -723,7 +723,7 @@ static int do_oid_object_info_extended(struct repository *r,
                        if ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))
                                die(_("replacement %s not found for %s"),
                                    oid_to_hex(real), oid_to_hex(oid));
-                       if ((p = has_packed_and_bad(r, real)))
+                       if ((p = has_packed_and_bad(odb->repo, real)))
                                die(_("packed object %s (stored in %s) is corrupt"),
                                    oid_to_hex(real), p->pack_name);
                }
@@ -736,10 +736,10 @@ static int do_oid_object_info_extended(struct repository *r,
                 * information below, so return early.
                 */
                return 0;
-       rtype = packed_object_info(r, e.p, e.offset, oi);
+       rtype = packed_object_info(odb->repo, e.p, e.offset, oi);
        if (rtype < 0) {
                mark_bad_packed_object(e.p, real);
-               return do_oid_object_info_extended(r, real, oi, 0);
+               return do_oid_object_info_extended(odb, real, oi, 0);
        } else if (oi->whence == OI_PACKED) {
                oi->u.packed.offset = e.offset;
                oi->u.packed.pack = e.p;
@@ -787,7 +787,7 @@ static int oid_object_info_convert(struct repository *r,
                oi = &new_oi;
        }
 
-       ret = oid_object_info_extended(r, &oid, oi, flags);
+       ret = odb_read_object_info_extended(r->objects, &oid, oi, flags);
        if (ret)
                return -1;
        if (oi == input_oi)
@@ -830,33 +830,35 @@ static int oid_object_info_convert(struct repository *r,
        return ret;
 }
 
-int oid_object_info_extended(struct repository *r, const struct object_id *oid,
-                            struct object_info *oi, unsigned flags)
+int odb_read_object_info_extended(struct object_database *odb,
+                                 const struct object_id *oid,
+                                 struct object_info *oi,
+                                 unsigned flags)
 {
        int ret;
 
-       if (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo))
-               return oid_object_info_convert(r, oid, oi, flags);
+       if (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo))
+               return oid_object_info_convert(odb->repo, oid, oi, flags);
 
        obj_read_lock();
-       ret = do_oid_object_info_extended(r, oid, oi, flags);
+       ret = do_oid_object_info_extended(odb, oid, oi, flags);
        obj_read_unlock();
        return ret;
 }
 
 
 /* returns enum object_type or negative */
-int oid_object_info(struct repository *r,
-                   const struct object_id *oid,
-                   unsigned long *sizep)
+int odb_read_object_info(struct object_database *odb,
+                        const struct object_id *oid,
+                        unsigned long *sizep)
 {
        enum object_type type;
        struct object_info oi = OBJECT_INFO_INIT;
 
        oi.typep = &type;
        oi.sizep = sizep;
-       if (oid_object_info_extended(r, oid, &oi,
-                                     OBJECT_INFO_LOOKUP_REPLACE) < 0)
+       if (odb_read_object_info_extended(odb, oid, &oi,
+                                         OBJECT_INFO_LOOKUP_REPLACE) < 0)
                return -1;
        return type;
 }
@@ -887,7 +889,7 @@ int pretend_object_file(struct repository *repo,
 
 /*
  * This function dies on corrupt objects; the callers who want to
- * deal with them should arrange to call oid_object_info_extended() and give
+ * deal with them should arrange to call odb_read_object_info_extended() and give
  * error messages themselves.
  */
 void *repo_read_object_file(struct repository *r,
@@ -902,7 +904,7 @@ void *repo_read_object_file(struct repository *r,
        oi.typep = type;
        oi.sizep = size;
        oi.contentp = &data;
-       if (oid_object_info_extended(r, oid, &oi, flags))
+       if (odb_read_object_info_extended(r->objects, oid, &oi, flags))
                return NULL;
 
        return data;
@@ -968,13 +970,13 @@ int has_object(struct repository *r, const struct object_id *oid,
        if (!(flags & HAS_OBJECT_FETCH_PROMISOR))
                object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;
 
-       return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;
+       return odb_read_object_info_extended(r->objects, oid, NULL, object_info_flags) >= 0;
 }
 
 void odb_assert_oid_type(struct object_database *odb,
                         const struct object_id *oid, enum object_type expect)
 {
-       enum object_type type = oid_object_info(odb->repo, oid, NULL);
+       enum object_type type = odb_read_object_info(odb, oid, NULL);
        if (type < 0)
                die(_("%s is not a valid object"), oid_to_hex(oid));
        if (type != expect)
diff --git a/odb.h b/odb.h
index 0ea9d4faa702250992e6a70aac5286cbf326e936..b37a9c5d20ffa3835c1fd2bfe9f74ea9314611aa 100644 (file)
--- a/odb.h
+++ b/odb.h
@@ -265,9 +265,6 @@ void *repo_read_object_file(struct repository *r,
                            enum object_type *type,
                            unsigned long *size);
 
-/* Read and unpack an object file into memory, write memory to an object file */
-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);
-
 /*
  * Add an object file to the in-memory object store, without writing it
  * to disk.
@@ -336,9 +333,24 @@ struct object_info {
 /* Die if object corruption (not just an object being missing) was detected. */
 #define OBJECT_INFO_DIE_IF_CORRUPT 32
 
-int oid_object_info_extended(struct repository *r,
-                            const struct object_id *,
-                            struct object_info *, unsigned flags);
+/*
+ * Read object info from the object database and populate the `object_info`
+ * structure. Returns 0 on success, a negative error code otherwise.
+ */
+int odb_read_object_info_extended(struct object_database *odb,
+                                 const struct object_id *oid,
+                                 struct object_info *oi,
+                                 unsigned flags);
+
+/*
+ * Read a subset of object info for the given object ID. Returns an `enum
+ * object_type` on success, a negative error code otherwise. If successful and
+ * `sizep` is non-NULL, then the size of the object will be written to the
+ * pointer.
+ */
+int odb_read_object_info(struct object_database *odb,
+                        const struct object_id *oid,
+                        unsigned long *sizep);
 
 enum {
        /* Retry packed storage after checking packed and loose storage */
@@ -360,7 +372,7 @@ void odb_assert_oid_type(struct object_database *odb,
 /*
  * Enabling the object read lock allows multiple threads to safely call the
  * following functions in parallel: repo_read_object_file(),
- * read_object_with_reference(), oid_object_info() and oid_object_info_extended().
+ * read_object_with_reference(), odb_read_object_info() and odb().
  *
  * obj_read_lock() and obj_read_unlock() may also be used to protect other
  * 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,
  * reading functions. However, beware that in these cases zlib inflation won't
  * be performed in parallel, losing performance.
  *
- * TODO: oid_object_info_extended()'s call stack has a recursive behavior. If
+ * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If
  * any of its callees end up calling it, this recursive call won't benefit from
  * parallel inflation.
  */
@@ -416,4 +428,22 @@ void *read_object_with_reference(struct repository *r,
                                 unsigned long *size,
                                 struct object_id *oid_ret);
 
+/* Compatibility wrappers, to be removed once Git 2.51 has been released. */
+#include "repository.h"
+
+static inline int oid_object_info_extended(struct repository *r,
+                                          const struct object_id *oid,
+                                          struct object_info *oi,
+                                          unsigned flags)
+{
+       return odb_read_object_info_extended(r->objects, oid, oi, flags);
+}
+
+static inline int oid_object_info(struct repository *r,
+                                 const struct object_id *oid,
+                                 unsigned long *sizep)
+{
+       return odb_read_object_info(r->objects, oid, sizep);
+}
+
 #endif /* ODB_H */
index c847369eaaad14cf57a49507dafd87fdda87edd5..c5183b619c12062344df8422c95a288123ce02b0 100644 (file)
@@ -144,8 +144,8 @@ void bitmap_writer_build_type_index(struct bitmap_writer *writer,
                        break;
 
                default:
-                       real_type = oid_object_info(writer->to_pack->repo,
-                                                   &entry->idx.oid, NULL);
+                       real_type = odb_read_object_info(writer->to_pack->repo->objects,
+                                                        &entry->idx.oid, NULL);
                        break;
                }
 
index a695a794e9b7039ec1e907cc51834984fb18d0f5..bcbb71f7502b7cb526ac1768bfe57ca06a70a510 100644 (file)
@@ -1868,8 +1868,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
                size_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git);
                struct eindex *eindex = &bitmap_git->ext_index;
                struct object *obj = eindex->objects[eindex_pos];
-               if (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,
-                                            &oi, 0) < 0)
+               if (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid,
+                                                 &oi, 0) < 0)
                        die(_("unable to get size of %s"), oid_to_hex(&obj->oid));
        }
 
@@ -3220,8 +3220,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)
                                       i)))
                        continue;
 
-               if (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid,
-                                            &oi, 0) < 0)
+               if (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects,
+                                                 &obj->oid, &oi, 0) < 0)
                        die(_("unable to get disk usage of '%s'"),
                            oid_to_hex(&obj->oid));
 
index ac0e29e99b9165204b72e1795a1e0f5c9b0cf891..af9ccfdba624abb3bac1c492bf9b2ac5259bd1a4 100644 (file)
@@ -1321,7 +1321,7 @@ static int retry_bad_packed_offset(struct repository *r,
                return OBJ_BAD;
        nth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));
        mark_bad_packed_object(p, &oid);
-       type = oid_object_info(r, &oid, NULL);
+       type = odb_read_object_info(r->objects, &oid, NULL);
        if (type <= OBJ_NONE)
                return OBJ_BAD;
        return type;
@@ -1849,7 +1849,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
                                oi.typep = &type;
                                oi.sizep = &base_size;
                                oi.contentp = &base;
-                               if (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)
+                               if (odb_read_object_info_extended(r->objects, &base_oid,
+                                                                 &oi, 0) < 0)
                                        base = NULL;
 
                                external_base = base;
index 2baa286bfd04bace2fff8f12bf27b180f38a493f..be6f82d12f847a64756bee4b1e120a92580b4bb8 100644 (file)
@@ -245,8 +245,8 @@ static int remove_fetched_oids(struct repository *repo,
        struct object_id *new_oids;
 
        for (i = 0; i < oid_nr; i++)
-               if (oid_object_info_extended(repo, &old_oids[i], NULL,
-                                            OBJECT_INFO_SKIP_FETCH_OBJECT)) {
+               if (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL,
+                                                 OBJECT_INFO_SKIP_FETCH_OBJECT)) {
                        remaining[i] = 1;
                        remaining_nr++;
                }
index 3022f69a1bd55ff461b36f0d18d72e0a9644a013..ecdd0dc58d5aabefb310fc231446ac6626f0d81c 100644 (file)
@@ -64,7 +64,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,
                strbuf_addstr(&send_buffer, oid_str);
 
                if (info->size) {
-                       if (oid_object_info(r, &oid, &object_size) < 0) {
+                       if (odb_read_object_info(r->objects, &oid, &object_size) < 0) {
                                strbuf_addstr(&send_buffer, " ");
                        } else {
                                strbuf_addf(&send_buffer, " %lu", object_size);
index 9dc748f0b9a0f7408b6ed11c5de3b96339369d05..e984b68a0c41e1064ea3a4adfa818dab7e33b8c6 100644 (file)
@@ -211,7 +211,7 @@ static void add_recent_object(const struct object_id *oid,
         * later processing, and the revision machinery expects
         * commits and tags to have been parsed.
         */
-       type = oid_object_info(the_repository, oid, NULL);
+       type = odb_read_object_info(the_repository->objects, oid, NULL);
        if (type < 0)
                die("unable to get object info for %s", oid_to_hex(oid));
 
index c3fa9686766375a5428d560cfddb13a68bed830d..7d5bccf95dcfc39a6abbc749815524e828faa97a 100644 (file)
@@ -3729,9 +3729,9 @@ void prefetch_cache_entries(const struct index_state *istate,
 
                if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
                        continue;
-               if (!oid_object_info_extended(the_repository, &ce->oid,
-                                             NULL,
-                                             OBJECT_INFO_FOR_PREFETCH))
+               if (!odb_read_object_info_extended(the_repository->objects,
+                                                  &ce->oid, NULL,
+                                                  OBJECT_INFO_FOR_PREFETCH))
                        continue;
                oid_array_append(&to_fetch, &ce->oid);
        }
index 4ce45440ad12cb62e39c7771942d1f4eb0174101..f9f2c512a8c6e02fbae8d32018e2227d0abb79a7 100644 (file)
@@ -2302,8 +2302,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
                oi->info.sizep = &oi->size;
                oi->info.typep = &oi->type;
        }
-       if (oid_object_info_extended(the_repository, &oi->oid, &oi->info,
-                                    OBJECT_INFO_LOOKUP_REPLACE))
+       if (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info,
+                                         OBJECT_INFO_LOOKUP_REPLACE))
                return strbuf_addf_ret(err, -1, _("missing object %s for %s"),
                                       oid_to_hex(&oi->oid), ref->refname);
        if (oi->info.disk_sizep && oi->disk_size < 0)
index 17a842f56847464d28daf6188414d88b40351d64..72c36239d31e34b7dbb3eb15e7eea0b3967bdcdb 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1182,7 +1182,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,
                BUG("'%s' is not a valid object, "
                    "match_explicit_lhs() should catch this!",
                    matched_src_name);
-       type = oid_object_info(the_repository, &oid, NULL);
+       type = odb_read_object_info(the_repository->objects, &oid, NULL);
        if (type == OBJ_COMMIT) {
                advise(_("The <src> part of the refspec is a commit object.\n"
                         "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
                        continue; /* not a tag */
                if (string_list_has_string(&dst_tag, ref->name))
                        continue; /* they already have it */
-               if (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)
+               if (odb_read_object_info(the_repository->objects,
+                                        &ref->new_oid, NULL) != OBJ_TAG)
                        continue; /* be conservative */
                item = string_list_append(&src_tag, ref->name);
                item->util = ref;
index 2432d0a39ec66988f9109952d9db7e5a82bd0060..193459405f8737577d7abe7a26a96fa777bf4146 100644 (file)
@@ -5503,9 +5503,8 @@ int sequencer_pick_revisions(struct repository *r,
 
                if (!repo_get_oid(r, name, &oid)) {
                        if (!lookup_commit_reference_gently(r, &oid, 1)) {
-                               enum object_type type = oid_object_info(r,
-                                                                       &oid,
-                                                                       NULL);
+                               enum object_type type = odb_read_object_info(r->objects,
+                                                                            &oid, NULL);
                                res = error(_("%s: can't cherry-pick a %s"),
                                            name, type_name(type));
                                goto out;
index 81c42673a235fa2cebd55ac6837e998829f89463..4b13827668e67a449860e087c45a01906126aa82 100644 (file)
@@ -44,7 +44,7 @@ struct git_istream {
 
        union {
                struct {
-                       char *buf; /* from oid_object_info_extended() */
+                       char *buf; /* from odb_read_object_info_extended() */
                        unsigned long read_ptr;
                } incore;
 
@@ -403,8 +403,8 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,
        oi.typep = type;
        oi.sizep = &st->size;
        oi.contentp = (void **)&st->u.incore.buf;
-       return oid_object_info_extended(r, oid, &oi,
-                                       OBJECT_INFO_DIE_IF_CORRUPT);
+       return odb_read_object_info_extended(r->objects, oid, &oi,
+                                            OBJECT_INFO_DIE_IF_CORRUPT);
 }
 
 /*****************************************************************************
@@ -422,7 +422,7 @@ static int istream_source(struct git_istream *st,
 
        oi.typep = type;
        oi.sizep = &size;
-       status = oid_object_info_extended(r, oid, &oi, 0);
+       status = odb_read_object_info_extended(r->objects, oid, &oi, 0);
        if (status < 0)
                return status;
 
index 788c9e55ed36061dbe525d3dd92d106d774074fd..f8373a9ea7decf33fdc3ad5fbccd527421b12e90 100644 (file)
@@ -968,7 +968,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
                return 0;
        }
 
-       type = oid_object_info(&subrepo, oid, NULL);
+       type = odb_read_object_info(subrepo.objects, oid, NULL);
 
        switch (type) {
        case OBJ_COMMIT:
@@ -1752,8 +1752,7 @@ static int fetch_start_failure(struct strbuf *err UNUSED,
 static int commit_missing_in_sub(const struct object_id *oid, void *data)
 {
        struct repository *subrepo = data;
-
-       enum object_type type = oid_object_info(subrepo, oid, NULL);
+       enum object_type type = odb_read_object_info(subrepo->objects, oid, NULL);
 
        return type != OBJ_COMMIT;
 }
index dba227259a26292d2a21e8ea983e2923c1ca8e56..d84880074930b268911b77314a79d536c5d19bf8 100644 (file)
@@ -23,7 +23,7 @@ static void object_info(const char *gitdir, const char *oid_hex)
                die("could not init repo");
        if (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo))
                die("could not parse oid");
-       if (oid_object_info_extended(&r, &oid, &oi, 0))
+       if (odb_read_object_info_extended(r.objects, &oid, &oi, 0))
                die("could not obtain object info");
        printf("%d\n", (int) size);
 
diff --git a/tag.c b/tag.c
index 5f6868bf7b12a4c33be8f225739996e04a483d62..144048fd5e0c252c530ee0d4cbd3f829cf5efdba 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
        unsigned long size;
        int ret;
 
-       type = oid_object_info(the_repository, oid, NULL);
+       type = odb_read_object_info(the_repository->objects, oid, NULL);
        if (type != OBJ_TAG)
                return error("%s: cannot verify a non-tag object of type %s.",
                                name_to_report ?