odb: rename `pretend_object_file()`

Rename `pretend_object_file()` to `odb_pretend_object()` to match other functions related to the object database and our modern coding guidelines. No compatibility wrapper is introduced as the function is not used a lot throughout our codebase. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jul 1, 2025 at 14:22 UTC 08218b8cd4b54468bbb7cd09454a630ca4209d1a
3 files changed +14 -13
blame.c
+2 -1
@@ -277,7 +277,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,
277 convert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);
278 origin->file.ptr = buf.buf;
279 origin->file.size = buf.len;
280 - pretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);
280 + odb_pretend_object(the_repository->objects, buf.buf, buf.len,
281 + OBJ_BLOB, &origin->blob_oid);
282
283 /*
284 * Read the current index, replace the path entry with
odb.c
+9 -9
@@ -863,21 +863,21 @@ int odb_read_object_info(struct object_database *odb,
863 return type;
864 }
865
866 -int pretend_object_file(struct repository *repo,
867 - void *buf, unsigned long len, enum object_type type,
868 - struct object_id *oid)
866 +int odb_pretend_object(struct object_database *odb,
867 + void *buf, unsigned long len, enum object_type type,
868 + struct object_id *oid)
869 {
870 struct cached_object_entry *co;
871 char *co_buf;
872
873 - hash_object_file(repo->hash_algo, buf, len, type, oid);
874 - if (odb_has_object(repo->objects, oid, 0) ||
875 - find_cached_object(repo->objects, oid))
873 + hash_object_file(odb->repo->hash_algo, buf, len, type, oid);
874 + if (odb_has_object(odb, oid, 0) ||
875 + find_cached_object(odb, oid))
876 return 0;
877
878 - ALLOC_GROW(repo->objects->cached_objects,
879 - repo->objects->cached_object_nr + 1, repo->objects->cached_object_alloc);
880 - co = &repo->objects->cached_objects[repo->objects->cached_object_nr++];
878 + ALLOC_GROW(odb->cached_objects,
879 + odb->cached_object_nr + 1, odb->cached_object_alloc);
880 + co = &odb->cached_objects[odb->cached_object_nr++];
881 co->value.size = len;
882 co->value.type = type;
883 co_buf = xmalloc(len);
odb.h
+3 -3
@@ -282,9 +282,9 @@ void *odb_read_object(struct object_database *odb,
282 * object in persistent storage before writing any other new objects
283 * that reference it.
284 */
285 -int pretend_object_file(struct repository *repo,
286 - void *buf, unsigned long len, enum object_type type,
287 - struct object_id *oid);
285 +int odb_pretend_object(struct object_database *odb,
286 + void *buf, unsigned long len, enum object_type type,
287 + struct object_id *oid);
288
289 struct object_info {
290 /* Request */