{"thread":{"id":"64119","subject":"[PATCH] odb: drop deprecated wrapper functions","startedAt":"2025-09-10T13:12:23Z","lastAt":"2025-09-10T15:38:04Z","messageCount":3,"participants":["Patrick Steinhardt","Justin Tobler","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"526027","messageId":"20250910-b4-pks-odb-drop-wrappers-v1-1-6ed660cb1eec@pks.im","threadId":"64119","inReplyTo":null,"subject":"[PATCH] odb: drop deprecated wrapper functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-09-10T13:12:17Z","receivedAt":"2025-09-10T13:12:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In the Git 2.51 release cycle we've refactored the object database layer\nto access objects via `struct object_database` directly. To make the\ntransition a bit easier we have retained some of the old-style functions\nin case those were widely used.\n\nNow that Git 2.51 has been released it's time to clean up though and\ndrop these old wrappers. Do so and adapt the small number of newly added\nusers to use the new functions instead.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/pack-objects.c      |  6 +++---\n odb.h                       | 33 ---------------------------------\n t/helper/test-pack-deltas.c | 10 ++++------\n 3 files changed, 7 insertions(+), 42 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 53a2256250..ff6900b654 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3774,7 +3774,7 @@ static void show_object_pack_hint(struct object *object, const char *name,\n \tenum stdin_packs_mode mode = *(enum stdin_packs_mode *)data;\n \tif (mode == STDIN_PACKS_MODE_FOLLOW) {\n \t\tif (object->type == OBJ_BLOB &&\n-\t\t    !has_object(the_repository, &object->oid, 0))\n+\t\t    !odb_has_object(the_repository->objects, &object->oid, 0))\n \t\t\treturn;\n \t\tadd_object_entry(&object->oid, object->type, name, 0);\n \t} else {\n@@ -4591,8 +4591,8 @@ static int add_objects_by_path(const char *path,\n \n \t\t/* Skip objects that do not exist locally. */\n \t\tif ((exclude_promisor_objects || arg_missing_action != MA_ERROR) &&\n-\t\t    oid_object_info_extended(the_repository, oid, &oi,\n-\t\t\t\t\t     OBJECT_INFO_FOR_PREFETCH) < 0)\n+\t\t    odb_read_object_info_extended(the_repository->objects, oid, &oi,\n+\t\t\t\t\t\t  OBJECT_INFO_FOR_PREFETCH) < 0)\n \t\t\tcontinue;\n \n \t\texclude = is_oid_uninteresting(the_repository, oid);\ndiff --git a/odb.h b/odb.h\nindex 3dfc66d75a..e8b9dff948 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -475,37 +475,4 @@ static inline int odb_write_object(struct object_database *odb,\n \treturn odb_write_object_ext(odb, buf, len, type, oid, NULL, 0);\n }\n \n-/* Compatibility wrappers, to be removed once Git 2.51 has been released. */\n-#include \"repository.h\"\n-\n-static inline int oid_object_info_extended(struct repository *r,\n-\t\t\t\t\t   const struct object_id *oid,\n-\t\t\t\t\t   struct object_info *oi,\n-\t\t\t\t\t   unsigned flags)\n-{\n-\treturn odb_read_object_info_extended(r->objects, oid, oi, flags);\n-}\n-\n-static inline int oid_object_info(struct repository *r,\n-\t\t\t\t  const struct object_id *oid,\n-\t\t\t\t  unsigned long *sizep)\n-{\n-\treturn odb_read_object_info(r->objects, oid, sizep);\n-}\n-\n-static inline void *repo_read_object_file(struct repository *r,\n-\t\t\t\t\t  const struct object_id *oid,\n-\t\t\t\t\t  enum object_type *type,\n-\t\t\t\t\t  unsigned long *size)\n-{\n-\treturn odb_read_object(r->objects, oid, type, size);\n-}\n-\n-static inline int has_object(struct repository *r,\n-\t\t\t     const struct object_id *oid,\n-\t\t\t     unsigned flags)\n-{\n-\treturn odb_has_object(r->objects, oid, flags);\n-}\n-\n #endif /* ODB_H */\ndiff --git a/t/helper/test-pack-deltas.c b/t/helper/test-pack-deltas.c\nindex 4caa024b1e..4981401eaa 100644\n--- a/t/helper/test-pack-deltas.c\n+++ b/t/helper/test-pack-deltas.c\n@@ -51,16 +51,14 @@ static void write_ref_delta(struct hashfile *f,\n \tunsigned long size, base_size, delta_size, compressed_size, hdrlen;\n \tenum object_type type;\n \tvoid *base_buf, *delta_buf;\n-\tvoid *buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t  oid, &type,\n-\t\t\t\t\t  &size);\n+\tvoid *buf = odb_read_object(the_repository->objects,\n+\t\t\t\t    oid, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"unable to read %s\", oid_to_hex(oid));\n \n-\tbase_buf = repo_read_object_file(the_repository,\n-\t\t\t\t\t base, &type,\n-\t\t\t\t\t &base_size);\n+\tbase_buf = odb_read_object(the_repository->objects,\n+\t\t\t\t   base, &type, &base_size);\n \n \tif (!base_buf)\n \t\tdie(\"unable to read %s\", oid_to_hex(base));\n\n---\nbase-commit: 4975ec3473b4bc61bc8a3df1ef29d0b7e7959e87\nchange-id: 20250910-b4-pks-odb-drop-wrappers-1ef5978e9b4f\n\n"},{"id":"526036","messageId":"fho5ch7r6d54tqxd56s4lcrv3ms6w4mytpbieere3qv3lz34zw@ufb22yd5w6xl","threadId":"64119","inReplyTo":"20250910-b4-pks-odb-drop-wrappers-v1-1-6ed660cb1eec@pks.im","subject":"Re: [PATCH] odb: drop deprecated wrapper functions","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-09-10T14:43:20Z","receivedAt":"2025-09-10T14:43:22Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/09/10 03:12PM, Patrick Steinhardt wrote:\n> diff --git a/odb.h b/odb.h\n> index 3dfc66d75a..e8b9dff948 100644\n> --- a/odb.h\n> +++ b/odb.h\n> @@ -475,37 +475,4 @@ static inline int odb_write_object(struct object_database *odb,\n>  \treturn odb_write_object_ext(odb, buf, len, type, oid, NULL, 0);\n>  }\n>  \n> -/* Compatibility wrappers, to be removed once Git 2.51 has been released. */\n> -#include \"repository.h\"\n> -\n> -static inline int oid_object_info_extended(struct repository *r,\n> -\t\t\t\t\t   const struct object_id *oid,\n> -\t\t\t\t\t   struct object_info *oi,\n> -\t\t\t\t\t   unsigned flags)\n> -{\n> -\treturn odb_read_object_info_extended(r->objects, oid, oi, flags);\n> -}\n> -\n> -static inline int oid_object_info(struct repository *r,\n> -\t\t\t\t  const struct object_id *oid,\n> -\t\t\t\t  unsigned long *sizep)\n> -{\n> -\treturn odb_read_object_info(r->objects, oid, sizep);\n> -}\n> -\n> -static inline void *repo_read_object_file(struct repository *r,\n> -\t\t\t\t\t  const struct object_id *oid,\n> -\t\t\t\t\t  enum object_type *type,\n> -\t\t\t\t\t  unsigned long *size)\n> -{\n> -\treturn odb_read_object(r->objects, oid, type, size);\n> -}\n> -\n> -static inline int has_object(struct repository *r,\n> -\t\t\t     const struct object_id *oid,\n> -\t\t\t     unsigned flags)\n> -{\n> -\treturn odb_has_object(r->objects, oid, flags);\n> -}\n> -\n>  #endif /* ODB_H */\n\nNice to see this cleanup. This patch looks obviously correct to me.\n\n-Justin\n"},{"id":"526054","messageId":"20250910153759.GA562601@coredump.intra.peff.net","threadId":"64119","inReplyTo":"20250910-b4-pks-odb-drop-wrappers-v1-1-6ed660cb1eec@pks.im","subject":"Re: [PATCH] odb: drop deprecated wrapper functions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2025-09-10T15:37:59Z","receivedAt":"2025-09-10T15:38:04Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 10, 2025 at 03:12:17PM +0200, Patrick Steinhardt wrote:\n\n> diff --git a/odb.h b/odb.h\n> index 3dfc66d75a..e8b9dff948 100644\n> --- a/odb.h\n> +++ b/odb.h\n> @@ -475,37 +475,4 @@ static inline int odb_write_object(struct object_database *odb,\n>  \treturn odb_write_object_ext(odb, buf, len, type, oid, NULL, 0);\n>  }\n>  \n> -/* Compatibility wrappers, to be removed once Git 2.51 has been released. */\n> -#include \"repository.h\"\n\nWhen merged to 'jch', this patch breaks the build. The issue is that\ncode added by ps/packfile-store was subtly depending on this include to\nhave access to the definition of \"struct repository\":\n\n  pack-objects.c: In function ‘prepare_in_pack_by_idx’:\n  pack-objects.c:89:51: error: invalid use of undefined type ‘struct repository’\n     89 |         struct packfile_store *packs = pdata->repo->objects->packfiles;\n        |                                                   ^~\n\nThe fix is probably just:\n\ndiff --git a/pack-objects.c b/pack-objects.c\nindex 668c113667..5b70aa400e 100644\n--- a/pack-objects.c\n+++ b/pack-objects.c\n@@ -4,6 +4,7 @@\n #include \"pack-objects.h\"\n #include \"packfile.h\"\n #include \"parse.h\"\n+#include \"repository.h\"\n \n static uint32_t locate_object_entry_hash(struct packing_data *pdata,\n \t\t\t\t\t const struct object_id *oid,\n\neither in the merge, or possibly in that other topic as a preparatory\nstep (I didn't look at how close it is to graduating to 'next').\n\n-Peff\n"}]}