* [PATCH] odb: drop deprecated wrapper functions
@ 2025-09-10 13:12 Patrick Steinhardt
2025-09-10 14:43 ` Justin Tobler
2025-09-10 15:37 ` Jeff King
0 siblings, 2 replies; 3+ messages in thread
From: Patrick Steinhardt @ 2025-09-10 13:12 UTC (permalink / raw)
To: git
In the Git 2.51 release cycle we've refactored the object database layer
to access objects via `struct object_database` directly. To make the
transition a bit easier we have retained some of the old-style functions
in case those were widely used.
Now that Git 2.51 has been released it's time to clean up though and
drop these old wrappers. Do so and adapt the small number of newly added
users to use the new functions instead.
Signed-off-by: Patrick Steinhardt <ps@pks•im>
---
builtin/pack-objects.c | 6 +++---
odb.h | 33 ---------------------------------
t/helper/test-pack-deltas.c | 10 ++++------
3 files changed, 7 insertions(+), 42 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 53a2256250..ff6900b654 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3774,7 +3774,7 @@ static void show_object_pack_hint(struct object *object, const char *name,
enum stdin_packs_mode mode = *(enum stdin_packs_mode *)data;
if (mode == STDIN_PACKS_MODE_FOLLOW) {
if (object->type == OBJ_BLOB &&
- !has_object(the_repository, &object->oid, 0))
+ !odb_has_object(the_repository->objects, &object->oid, 0))
return;
add_object_entry(&object->oid, object->type, name, 0);
} else {
@@ -4591,8 +4591,8 @@ static int add_objects_by_path(const char *path,
/* Skip objects that do not exist locally. */
if ((exclude_promisor_objects || arg_missing_action != MA_ERROR) &&
- oid_object_info_extended(the_repository, oid, &oi,
- OBJECT_INFO_FOR_PREFETCH) < 0)
+ odb_read_object_info_extended(the_repository->objects, oid, &oi,
+ OBJECT_INFO_FOR_PREFETCH) < 0)
continue;
exclude = is_oid_uninteresting(the_repository, oid);
diff --git a/odb.h b/odb.h
index 3dfc66d75a..e8b9dff948 100644
--- a/odb.h
+++ b/odb.h
@@ -475,37 +475,4 @@ static inline int odb_write_object(struct object_database *odb,
return odb_write_object_ext(odb, buf, len, type, oid, NULL, 0);
}
-/* 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);
-}
-
-static inline void *repo_read_object_file(struct repository *r,
- const struct object_id *oid,
- enum object_type *type,
- unsigned long *size)
-{
- return odb_read_object(r->objects, oid, type, size);
-}
-
-static inline int has_object(struct repository *r,
- const struct object_id *oid,
- unsigned flags)
-{
- return odb_has_object(r->objects, oid, flags);
-}
-
#endif /* ODB_H */
diff --git a/t/helper/test-pack-deltas.c b/t/helper/test-pack-deltas.c
index 4caa024b1e..4981401eaa 100644
--- a/t/helper/test-pack-deltas.c
+++ b/t/helper/test-pack-deltas.c
@@ -51,16 +51,14 @@ static void write_ref_delta(struct hashfile *f,
unsigned long size, base_size, delta_size, compressed_size, hdrlen;
enum object_type type;
void *base_buf, *delta_buf;
- void *buf = repo_read_object_file(the_repository,
- oid, &type,
- &size);
+ void *buf = odb_read_object(the_repository->objects,
+ oid, &type, &size);
if (!buf)
die("unable to read %s", oid_to_hex(oid));
- base_buf = repo_read_object_file(the_repository,
- base, &type,
- &base_size);
+ base_buf = odb_read_object(the_repository->objects,
+ base, &type, &base_size);
if (!base_buf)
die("unable to read %s", oid_to_hex(base));
---
base-commit: 4975ec3473b4bc61bc8a3df1ef29d0b7e7959e87
change-id: 20250910-b4-pks-odb-drop-wrappers-1ef5978e9b4f
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] odb: drop deprecated wrapper functions
2025-09-10 13:12 [PATCH] odb: drop deprecated wrapper functions Patrick Steinhardt
@ 2025-09-10 14:43 ` Justin Tobler
2025-09-10 15:37 ` Jeff King
1 sibling, 0 replies; 3+ messages in thread
From: Justin Tobler @ 2025-09-10 14:43 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: git
On 25/09/10 03:12PM, Patrick Steinhardt wrote:
> diff --git a/odb.h b/odb.h
> index 3dfc66d75a..e8b9dff948 100644
> --- a/odb.h
> +++ b/odb.h
> @@ -475,37 +475,4 @@ static inline int odb_write_object(struct object_database *odb,
> return odb_write_object_ext(odb, buf, len, type, oid, NULL, 0);
> }
>
> -/* 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);
> -}
> -
> -static inline void *repo_read_object_file(struct repository *r,
> - const struct object_id *oid,
> - enum object_type *type,
> - unsigned long *size)
> -{
> - return odb_read_object(r->objects, oid, type, size);
> -}
> -
> -static inline int has_object(struct repository *r,
> - const struct object_id *oid,
> - unsigned flags)
> -{
> - return odb_has_object(r->objects, oid, flags);
> -}
> -
> #endif /* ODB_H */
Nice to see this cleanup. This patch looks obviously correct to me.
-Justin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] odb: drop deprecated wrapper functions
2025-09-10 13:12 [PATCH] odb: drop deprecated wrapper functions Patrick Steinhardt
2025-09-10 14:43 ` Justin Tobler
@ 2025-09-10 15:37 ` Jeff King
1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2025-09-10 15:37 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: Junio C Hamano, git
On Wed, Sep 10, 2025 at 03:12:17PM +0200, Patrick Steinhardt wrote:
> diff --git a/odb.h b/odb.h
> index 3dfc66d75a..e8b9dff948 100644
> --- a/odb.h
> +++ b/odb.h
> @@ -475,37 +475,4 @@ static inline int odb_write_object(struct object_database *odb,
> return odb_write_object_ext(odb, buf, len, type, oid, NULL, 0);
> }
>
> -/* Compatibility wrappers, to be removed once Git 2.51 has been released. */
> -#include "repository.h"
When merged to 'jch', this patch breaks the build. The issue is that
code added by ps/packfile-store was subtly depending on this include to
have access to the definition of "struct repository":
pack-objects.c: In function ‘prepare_in_pack_by_idx’:
pack-objects.c:89:51: error: invalid use of undefined type ‘struct repository’
89 | struct packfile_store *packs = pdata->repo->objects->packfiles;
| ^~
The fix is probably just:
diff --git a/pack-objects.c b/pack-objects.c
index 668c113667..5b70aa400e 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -4,6 +4,7 @@
#include "pack-objects.h"
#include "packfile.h"
#include "parse.h"
+#include "repository.h"
static uint32_t locate_object_entry_hash(struct packing_data *pdata,
const struct object_id *oid,
either in the merge, or possibly in that other topic as a preparatory
step (I didn't look at how close it is to graduating to 'next').
-Peff
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-10 15:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-10 13:12 [PATCH] odb: drop deprecated wrapper functions Patrick Steinhardt
2025-09-10 14:43 ` Justin Tobler
2025-09-10 15:37 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox