aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-07-01 14:22:25 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-01 14:46:37 -0700
commite989dd96b8aa9b20b0e23d3fa845d0baba1b454a (patch)
tree8f205f5e7ec243777ec9ca46069575cf77164ecf
parentodb: trivial refactorings to get rid of `the_repository` (diff)
downloadgit-e989dd96b8aa9b20b0e23d3fa845d0baba1b454a.tar.gz
git-e989dd96b8aa9b20b0e23d3fa845d0baba1b454a.zip
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>
-rw-r--r--archive.c2
-rw-r--r--blame.c4
-rw-r--r--builtin/blame.c4
-rw-r--r--builtin/cat-file.c26
-rw-r--r--builtin/describe.c3
-rw-r--r--builtin/fast-export.c2
-rw-r--r--builtin/fast-import.c17
-rw-r--r--builtin/fsck.c7
-rw-r--r--builtin/gc.c2
-rw-r--r--builtin/grep.c2
-rw-r--r--builtin/index-pack.c13
-rw-r--r--builtin/ls-files.c2
-rw-r--r--builtin/ls-tree.c4
-rw-r--r--builtin/mktree.c8
-rw-r--r--builtin/pack-objects.c30
-rw-r--r--builtin/prune.c4
-rw-r--r--builtin/repack.c2
-rw-r--r--builtin/replace.c10
-rw-r--r--builtin/rev-list.c6
-rw-r--r--builtin/tag.c4
-rw-r--r--builtin/unpack-objects.c2
-rw-r--r--commit-graph.c2
-rw-r--r--commit.c3
-rw-r--r--diff.c18
-rw-r--r--fetch-pack.c4
-rw-r--r--list-objects-filter.c2
-rw-r--r--log-tree.c2
-rw-r--r--merge-ort.c4
-rw-r--r--object-file.c2
-rw-r--r--object-file.h2
-rw-r--r--object-name.c16
-rw-r--r--object.c6
-rw-r--r--odb.c60
-rw-r--r--odb.h46
-rw-r--r--pack-bitmap-write.c4
-rw-r--r--pack-bitmap.c8
-rw-r--r--packfile.c5
-rw-r--r--promisor-remote.c4
-rw-r--r--protocol-caps.c2
-rw-r--r--reachable.c2
-rw-r--r--read-cache.c6
-rw-r--r--ref-filter.c4
-rw-r--r--remote.c5
-rw-r--r--sequencer.c5
-rw-r--r--streaming.c8
-rw-r--r--submodule.c5
-rw-r--r--t/helper/test-partial-clone.c2
-rw-r--r--tag.c2
48 files changed, 213 insertions, 170 deletions
diff --git a/archive.c b/archive.c
index 7fa2cc2596..f2511d530d 100644
--- 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 0ceea080a8..97db3355af 100644
--- 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:
diff --git a/builtin/blame.c b/builtin/blame.c
index 15eda60af9..91586e6852 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -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;
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index f3a925a818..f7595fdb04 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -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));
diff --git a/builtin/describe.c b/builtin/describe.c
index 96cb68e5e5..fbf305d762 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -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);
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 0505f289a9..6c93cf0a8a 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -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));
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 413304db9b..2718376f2c 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -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! */
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 014aa1344e..6e3465b026 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -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);
}
diff --git a/builtin/gc.c b/builtin/gc.c
index 50a09eb07e..ff551fab43 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -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);
diff --git a/builtin/grep.c b/builtin/grep.c
index cfcf916bce..1435d462cd 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -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,
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 4d4d989eb1..d0b1690812 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -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)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 821339b07d..ff975e7be0 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -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)
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 62b6fd58c1..4d616dd528 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -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),
diff --git a/builtin/mktree.c b/builtin/mktree.c
index 016b0e5b22..81df7f6099 100644
--- a/builtin/mktree.c
+++ b/builtin/mktree.c
@@ -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) {
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 99b63cb098..da35d68408 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -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;
}
diff --git a/builtin/prune.c b/builtin/prune.c
index 7bbfb14c2b..339017c7cc 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -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");
}
diff --git a/builtin/repack.c b/builtin/repack.c
index 8145474cf8..a89c2b704f 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -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 ? "+" : "",
diff --git a/builtin/replace.c b/builtin/replace.c
index 11c7e2d4c0..5ff2ab723c 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -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));
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 0ee37a32cb..4d0c460f18 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -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;
}
diff --git a/builtin/tag.c b/builtin/tag.c
index cf2ea4b499..e0b27396c6 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -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");
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 7bf395eec8..405e78bc59 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -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;
diff --git a/commit-graph.c b/commit-graph.c
index 59265f8938..5f482d3377 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -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));
diff --git a/commit.c b/commit.c
index aa65183d8b..d4aa9c7a5f 100644
--- 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 3af108115b..dca87e164f 100644
--- 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);
}
diff --git a/fetch-pack.c b/fetch-pack.c
index 47fa7fa4c4..0f5de1c94d 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -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 *)
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 80fe48a52c..7ecd4d9ef5 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -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
diff --git a/log-tree.c b/log-tree.c
index 1d05dc1c70..233bf9f227 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -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);
diff --git a/merge-ort.c b/merge-ort.c
index 9f693ab1d3..f29417040c 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -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);
}
}
diff --git a/object-file.c b/object-file.c
index 04da19a1a3..3d674d1093 100644
--- a/object-file.c
+++ b/object-file.c
@@ -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))
diff --git a/object-file.h b/object-file.h
index 5066638f8e..67b4ffc480 100644
--- a/object-file.h
+++ b/object-file.h
@@ -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.
diff --git a/object-name.c b/object-name.c
index 381536e900..e225eb602c 100644
--- a/object-name.c
+++ b/object-name.c
@@ -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;
diff --git a/object.c b/object.c
index 3b15469139..868d89eed4 100644
--- 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 5a88701550..40eacdfe2d 100644
--- 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 0ea9d4faa7..b37a9c5d20 100644
--- 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 */
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index c847369eaa..c5183b619c 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -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;
}
diff --git a/pack-bitmap.c b/pack-bitmap.c
index a695a794e9..bcbb71f750 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -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));
diff --git a/packfile.c b/packfile.c
index ac0e29e99b..af9ccfdba6 100644
--- a/packfile.c
+++ b/packfile.c
@@ -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;
diff --git a/promisor-remote.c b/promisor-remote.c
index 2baa286bfd..be6f82d12f 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -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++;
}
diff --git a/protocol-caps.c b/protocol-caps.c
index 3022f69a1b..ecdd0dc58d 100644
--- a/protocol-caps.c
+++ b/protocol-caps.c
@@ -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);
diff --git a/reachable.c b/reachable.c
index 9dc748f0b9..e984b68a0c 100644
--- a/reachable.c
+++ b/reachable.c
@@ -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));
diff --git a/read-cache.c b/read-cache.c
index c3fa968676..7d5bccf95d 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -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);
}
diff --git a/ref-filter.c b/ref-filter.c
index 4ce45440ad..f9f2c512a8 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -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)
diff --git a/remote.c b/remote.c
index 17a842f568..72c36239d3 100644
--- 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;
diff --git a/sequencer.c b/sequencer.c
index 2432d0a39e..193459405f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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;
diff --git a/streaming.c b/streaming.c
index 81c42673a2..4b13827668 100644
--- a/streaming.c
+++ b/streaming.c
@@ -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;
diff --git a/submodule.c b/submodule.c
index 788c9e55ed..f8373a9ea7 100644
--- a/submodule.c
+++ b/submodule.c
@@ -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;
}
diff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c
index dba227259a..d848800749 100644
--- a/t/helper/test-partial-clone.c
+++ b/t/helper/test-partial-clone.c
@@ -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 5f6868bf7b..144048fd5e 100644
--- 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 ?