]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb: convert `odb_has_object()` flags into an enum
authorPatrick Steinhardt <ps@pks.im>
Thu, 12 Feb 2026 06:59:41 +0000 (07:59 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 12 Feb 2026 19:05:08 +0000 (11:05 -0800)
Following the reason in the preceding commit, convert the
`odb_has_object()` flags into an enum.

With this change, we would have catched the misuse of `odb_has_object()`
that was fixed in a preceding commit as the compiler would have
generated a warning:

  ../builtin/backfill.c:71:9: error: implicit conversion from enumeration type 'enum odb_object_info_flag' to different enumeration type 'enum odb_has_object_flag' [-Werror,-Wenum-conversion]
     70 |                 if (!odb_has_object(ctx->repo->objects, &list->oid[i],
        |                      ~~~~~~~~~~~~~~
     71 |                                     OBJECT_INFO_FOR_PREFETCH))
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb.c
odb.h

diff --git a/odb.c b/odb.c
index d437aa8b0614488f8f9e91ec770fd240601f1454..2bbbfb344ae3221b1711ce579798e2398471afaf 100644 (file)
--- a/odb.c
+++ b/odb.c
@@ -964,7 +964,7 @@ void *odb_read_object_peeled(struct object_database *odb,
 }
 
 int odb_has_object(struct object_database *odb, const struct object_id *oid,
-              unsigned flags)
+                  enum has_object_flags flags)
 {
        unsigned object_info_flags = 0;
 
diff --git a/odb.h b/odb.h
index e94cdc3665da4759c57578f0b4e6312b6c785c20..f7368827aca8f64379d4fc99251672be1a59730f 100644 (file)
--- a/odb.h
+++ b/odb.h
@@ -395,7 +395,7 @@ int odb_read_object_info(struct object_database *odb,
                         const struct object_id *oid,
                         unsigned long *sizep);
 
-enum {
+enum has_object_flags {
        /* Retry packed storage after checking packed and loose storage */
        HAS_OBJECT_RECHECK_PACKED = (1 << 0),
        /* Allow fetching the object in case the repository has a promisor remote. */
@@ -408,7 +408,7 @@ enum {
  */
 int odb_has_object(struct object_database *odb,
                   const struct object_id *oid,
-                  unsigned flags);
+                  enum has_object_flags flags);
 
 int odb_freshen_object(struct object_database *odb,
                       const struct object_id *oid);