odb: rename repo_read_object_file()

Rename `repo_read_object_file()` to `odb_read_object()` to match other
functions related to the object database and our modern coding
guidelines.

Introduce a compatibility wrapper 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>
This commit is contained in:
Patrick Steinhardt
2025-07-01 14:22:26 +02:00
committed by Junio C Hamano
parent e989dd96b8
commit d4ff88aee3
47 changed files with 157 additions and 150 deletions

View File

@@ -74,7 +74,7 @@ static int filter_object(const char *path, unsigned mode,
{
enum object_type type;
*buf = repo_read_object_file(the_repository, oid, &type, size);
*buf = odb_read_object(the_repository->objects, oid, &type, size);
if (!*buf)
return error(_("cannot read object %s '%s'"),
oid_to_hex(oid), path);
@@ -197,8 +197,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
ret = stream_blob(&oid);
goto cleanup;
}
buf = repo_read_object_file(the_repository, &oid, &type,
&size);
buf = odb_read_object(the_repository->objects, &oid,
&type, &size);
if (!buf)
die("Cannot read object %s", obj_name);
@@ -219,10 +219,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
struct object_id blob_oid;
if (odb_read_object_info(the_repository->objects,
&oid, NULL) == OBJ_TAG) {
char *buffer = repo_read_object_file(the_repository,
&oid,
&type,
&size);
char *buffer = odb_read_object(the_repository->objects,
&oid, &type, &size);
const char *target;
if (!buffer)
@@ -403,10 +401,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
if (!textconv_object(the_repository,
data->rest, 0100644, oid,
1, &contents, &size))
contents = repo_read_object_file(the_repository,
oid,
&type,
&size);
contents = odb_read_object(the_repository->objects,
oid, &type, &size);
if (!contents)
die("could not convert '%s' %s",
oid_to_hex(oid), data->rest);
@@ -423,8 +419,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
unsigned long size;
void *contents;
contents = repo_read_object_file(the_repository, oid, &type,
&size);
contents = odb_read_object(the_repository->objects, oid,
&type, &size);
if (!contents)
die("object %s disappeared", oid_to_hex(oid));
@@ -533,8 +529,8 @@ static void batch_object_write(const char *obj_name,
size_t s = data->size;
char *buf = NULL;
buf = repo_read_object_file(the_repository, &data->oid, &data->type,
&data->size);
buf = odb_read_object(the_repository->objects, &data->oid,
&data->type, &data->size);
if (!buf)
die(_("unable to read %s"), oid_to_hex(&data->oid));
buf = replace_idents_using_mailmap(buf, &s);

View File

@@ -320,7 +320,7 @@ static char *get_symlink(struct repository *repo,
} else {
enum object_type type;
unsigned long size;
data = repo_read_object_file(repo, oid, &type, &size);
data = odb_read_object(repo->objects, oid, &type, &size);
if (!data)
die(_("could not read object %s for symlink %s"),
oid_to_hex(oid), path);

View File

@@ -323,7 +323,7 @@ static void export_blob(const struct object_id *oid)
object = (struct object *)lookup_blob(the_repository, oid);
eaten = 0;
} else {
buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf)
die("could not read blob %s", oid_to_hex(oid));
if (check_object_signature(the_repository, oid, buf, size,
@@ -869,8 +869,8 @@ static void handle_tag(const char *name, struct tag *tag)
return;
}
buf = repo_read_object_file(the_repository, &tag->object.oid, &type,
&size);
buf = odb_read_object(the_repository->objects, &tag->object.oid,
&type, &size);
if (!buf)
die("could not read tag %s", oid_to_hex(&tag->object.oid));
message = memmem(buf, size, "\n\n", 2);

View File

@@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root)
die("Can't load tree %s", oid_to_hex(oid));
} else {
enum object_type type;
buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf || type != OBJ_TREE)
die("Can't load tree %s", oid_to_hex(oid));
}
@@ -3002,7 +3002,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
char *buf;
if (!oe || oe->pack_id == MAX_PACK_ID) {
buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
} else {
type = oe->type;
buf = gfi_unpack_entry(oe, &size);
@@ -3110,8 +3110,8 @@ static struct object_entry *dereference(struct object_entry *oe,
buf = gfi_unpack_entry(oe, &size);
} else {
enum object_type unused;
buf = repo_read_object_file(the_repository, oid, &unused,
&size);
buf = odb_read_object(the_repository->objects, oid,
&unused, &size);
}
if (!buf)
die("Can't load object %s", oid_to_hex(oid));

View File

@@ -573,8 +573,8 @@ static int grep_cache(struct grep_opt *opt,
void *data;
unsigned long size;
data = repo_read_object_file(the_repository, &ce->oid,
&type, &size);
data = odb_read_object(the_repository->objects, &ce->oid,
&type, &size);
if (!data)
die(_("unable to read tree %s"), oid_to_hex(&ce->oid));
init_tree_desc(&tree, &ce->oid, data, size);
@@ -666,8 +666,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
void *data;
unsigned long size;
data = repo_read_object_file(the_repository,
&entry.oid, &type, &size);
data = odb_read_object(the_repository->objects,
&entry.oid, &type, &size);
if (!data)
die(_("unable to read tree (%s)"),
oid_to_hex(&entry.oid));

View File

@@ -914,8 +914,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
die(_("cannot read existing object info %s"), oid_to_hex(oid));
if (has_type != type || has_size != size)
die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
has_data = repo_read_object_file(the_repository, oid,
&has_type, &has_size);
has_data = odb_read_object(the_repository->objects, oid,
&has_type, &has_size);
read_unlock();
if (!data)
data = new_data = get_data_from_pack(obj_entry);
@@ -1521,8 +1521,8 @@ static void fix_unresolved_deltas(struct hashfile *f)
if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
continue;
data = repo_read_object_file(the_repository, &d->oid, &type,
&size);
data = odb_read_object(the_repository->objects, &d->oid,
&type, &size);
if (!data)
continue;

View File

@@ -714,7 +714,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
{
unsigned long size;
enum object_type type;
char *buf = repo_read_object_file(the_repository, oid, &type, &size);
char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
unsigned long offset = 0;
if (!buf)

View File

@@ -75,9 +75,9 @@ static void *result(struct merge_list *entry, unsigned long *size)
const char *path = entry->path;
if (!entry->stage)
return repo_read_object_file(the_repository,
&entry->blob->object.oid, &type,
size);
return odb_read_object(the_repository->objects,
&entry->blob->object.oid, &type,
size);
base = NULL;
if (entry->stage == 1) {
base = entry->blob;
@@ -100,9 +100,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)
enum object_type type;
while (entry) {
if (entry->stage == 2)
return repo_read_object_file(the_repository,
&entry->blob->object.oid,
&type, size);
return odb_read_object(the_repository->objects,
&entry->blob->object.oid,
&type, size);
entry = entry->link;
}
return NULL;

View File

@@ -54,8 +54,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
void *buffer;
const struct object_id *repl;
buffer = repo_read_object_file(the_repository, tagged_oid, &type,
&size);
buffer = odb_read_object(the_repository->objects, tagged_oid,
&type, &size);
if (!buffer)
die(_("could not read tagged object '%s'"),
oid_to_hex(tagged_oid));

View File

@@ -152,7 +152,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)
{
unsigned long size;
enum object_type type;
char *buf = repo_read_object_file(the_repository, oid, &type, &size);
char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (buf) {
if (size)
write_or_die(fd, buf, size);
@@ -319,7 +319,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
strbuf_init(&msg->buf, 0);
if (repo_get_oid(the_repository, arg, &object))
die(_("failed to resolve '%s' as a valid ref."), arg);
if (!(value = repo_read_object_file(the_repository, &object, &type, &len)))
if (!(value = odb_read_object(the_repository->objects, &object, &type, &len)))
die(_("failed to read object '%s'."), arg);
if (type != OBJ_BLOB) {
strbuf_release(&msg->buf);
@@ -722,7 +722,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,
unsigned long size;
enum object_type type;
struct strbuf buf = STRBUF_INIT;
char *prev_buf = repo_read_object_file(the_repository, note, &type, &size);
char *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);
if (!prev_buf)
die(_("unable to read %s"), oid_to_hex(note));

View File

@@ -337,13 +337,13 @@ static void *get_delta(struct object_entry *entry)
void *buf, *base_buf, *delta_buf;
enum object_type type;
buf = repo_read_object_file(the_repository, &entry->idx.oid, &type,
&size);
buf = odb_read_object(the_repository->objects, &entry->idx.oid,
&type, &size);
if (!buf)
die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
base_buf = repo_read_object_file(the_repository,
&DELTA(entry)->idx.oid, &type,
&base_size);
base_buf = odb_read_object(the_repository->objects,
&DELTA(entry)->idx.oid, &type,
&base_size);
if (!base_buf)
die("unable to read %s",
oid_to_hex(&DELTA(entry)->idx.oid));
@@ -506,9 +506,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
&size, NULL)) != NULL)
buf = NULL;
else {
buf = repo_read_object_file(the_repository,
&entry->idx.oid, &type,
&size);
buf = odb_read_object(the_repository->objects,
&entry->idx.oid, &type,
&size);
if (!buf)
die(_("unable to read %s"),
oid_to_hex(&entry->idx.oid));
@@ -1895,7 +1895,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
/* Did not find one. Either we got a bogus request or
* we need to read and perhaps cache.
*/
data = repo_read_object_file(the_repository, oid, &type, &size);
data = odb_read_object(the_repository->objects, oid, &type, &size);
if (!data)
return NULL;
if (type != OBJ_TREE) {
@@ -2762,9 +2762,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
/* Load data if not already done */
if (!trg->data) {
packing_data_lock(&to_pack);
trg->data = repo_read_object_file(the_repository,
&trg_entry->idx.oid, &type,
&sz);
trg->data = odb_read_object(the_repository->objects,
&trg_entry->idx.oid, &type,
&sz);
packing_data_unlock(&to_pack);
if (!trg->data)
die(_("object %s cannot be read"),
@@ -2777,9 +2777,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
}
if (!src->data) {
packing_data_lock(&to_pack);
src->data = repo_read_object_file(the_repository,
&src_entry->idx.oid, &type,
&sz);
src->data = odb_read_object(the_repository->objects,
&src_entry->idx.oid, &type,
&sz);
packing_data_unlock(&to_pack);
if (!src->data) {
if (src_entry->preferred_base) {

View File

@@ -244,7 +244,7 @@ static void write_tag_body(int fd, const struct object_id *oid)
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;
orig = buf = repo_read_object_file(the_repository, oid, &type, &size);
orig = buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf)
return;
if (parse_signature(buf, size, &payload, &signature)) {
@@ -407,7 +407,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
strbuf_addstr(sb, "object of unknown type");
break;
case OBJ_COMMIT:
if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {
if ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) {
subject_len = find_commit_subject(buf, &subject_start);
strbuf_insert(sb, sb->len, subject_start, subject_len);
} else {

View File

@@ -14,7 +14,7 @@ static char *create_temp_file(struct object_id *oid)
unsigned long size;
int fd;
buf = repo_read_object_file(the_repository, oid, &type, &size);
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf || type != OBJ_BLOB)
die("unable to read blob object %s", oid_to_hex(oid));

View File

@@ -516,8 +516,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
if (resolve_against_held(nr, &base_oid, delta_data, delta_size))
return;
base = repo_read_object_file(the_repository, &base_oid, &type,
&base_size);
base = odb_read_object(the_repository->objects, &base_oid,
&type, &base_size);
if (!base) {
error("failed to read delta-pack base object %s",
oid_to_hex(&base_oid));