git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 5/5] odb: convert `odb_has_object()` flags into an enum

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 12, 2026, 06:59 UTC
Message-ID
<20260212-b4-pks-read-object-info-flags-v2-5-3bfa9bb149ef@pks.im>
In-Reply-To
<20260212-b4-pks-read-object-info-flags-v2-0-3bfa9bb149ef@pks.im>

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>
---
 odb.c | 2 +-
 odb.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/odb.c b/odb.c
index d437aa8b06..2bbbfb344a 100644
--- 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 e94cdc3665..f7368827ac 100644
--- 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);
-- 
2.53.0.295.g64333814d3.dirty
Previous: Patrick Steinhardt
Message 23 of 23 in “Small fixups for `OBJECT_INFO` flags”
  1. 0/3 Small fixups for `OBJECT_INFO` flagsPatrick Steinhardt, Jan 26, 2026
  2. 1/3 builtin/backfill: fix flags passed to `odb_has_object()`Patrick Steinhardt, Jan 26, 2026
  3. Derrick StoleeJan 26, 2026
  4. Junio C HamanoJan 26, 2026
  5. Justin ToblerFeb 9, 2026
  6. Karthik NayakFeb 10, 2026
  7. Karthik NayakFeb 10, 2026
  8. 2/3 builtin/fsck: fix flags passed to `odb_has_object()`Patrick Steinhardt, Jan 26, 2026
  9. Justin ToblerFeb 9, 2026
  10. 3/3 odb: drop gaps in object info flag valuesPatrick Steinhardt, Jan 26, 2026
  11. Junio C HamanoJan 26, 2026
  12. René ScharfeJan 26, 2026
  13. Junio C HamanoJan 26, 2026
  14. Patrick SteinhardtJan 27, 2026
  15. Justin ToblerFeb 9, 2026
  16. Justin ToblerFeb 9, 2026
  17. Junio C HamanoJan 26, 2026
  18. 0/5 Small fixups for `OBJECT_INFO` flagsPatrick Steinhardt, Feb 12, 2026
  19. 1/5 builtin/backfill: fix flags passed to `odb_has_object()`Patrick Steinhardt, Feb 12, 2026
  20. 2/5 builtin/fsck: fix flags passed to `odb_has_object()`Patrick Steinhardt, Feb 12, 2026
  21. 3/5 odb: drop gaps in object info flag valuesPatrick Steinhardt, Feb 12, 2026
  22. 4/5 odb: convert object info flags into an enumPatrick Steinhardt, Feb 12, 2026
  23. 5/5 odb: convert `odb_has_object()` flags into an enumPatrick Steinhardt, Feb 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.