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

Re: [PATCH v3 04/14] object-file: introduce function to iterate through objects

From
Taylor Blau <me@ttaylorr.com>
Date
Jan 22, 2026, 00:15 UTC
Message-ID
<aXFsFAV/1J9DLQRY@nand.local>
In-Reply-To
<20260121-pks-odb-for-each-object-v3-4-12c4dfd24227@pks.im>
On Wed, Jan 21, 2026 at 01:50:20PM +0100, Patrick Steinhardt wrote:
> Introduce a new function `odb_source_loose_for_each_object()` to plug
> this gap. This function doesn't take any data specific to loose objects,
> but instead it accepts a `struct object_info` that will be populated the
> exact same as if `odb_source_loose_read_object()` was called.

This may be a bit of a tangent, but I wonder if we are over-applying the function prefixing convention.

In general I am really happy with this convention, and it yields organized headers where functions are clearly grouped by what structure they operate on. But I have noticed a handful of times where we replaced a very concise function name with a longer prefixed version.

I think I don't have a clear sense of what the benefit of prefixing is in this particular instance. Supposing for a moment that we don't have an existing for_each_loose_object() function (which I think is the end-state of this series). What does the name "odb_source_loose_for_each_object()" convey that "for_each_loose_object()" does not?

I think if there were multiple ways to iterate over loose objects, it makes a lot of sense to prefix them such that they are grouped to avoid mixing interfaces or using one API when you meant to call another. But my understanding is that the intent here is to consolidate all of the different ways to iterate over objects which live in different odb_source implementations opaque to the caller. As a result, what other way exists to iterate over loose objects?

Another aspect of this is how approachable the function is to newcomers. On the one hand, I can see an argument that prefixing makes it clear which functions belong together, and so if a newcomer is familiar with the concept of ODB sources, then they should reasonably expect that a function to iterate over loose objects would begin with "odb_source_".

But on the other hand, while a newcomer may be familiar with the basics of Git's object model enough to understand the distinction between loose and packed objects, they may not be familiar with the concept of an ODB source. In that case, the prefix makes it somewhat more difficult to find the right function to use.

I think there is a reasonable argument towards prefixing in the case that we want to link against this function from outside of Git. But AFAIK that is not likely to happen in the near future. So in the interim I think we are left with function names which are a little more verbose than the ones they are replacing without a clear benefit.

To be clear, I am generally in favor of this convention and have been applying it myself especially when splitting out the repack builtin implementation into their own compilation units. But I wonder if we could relax the convention in cases like these without sacrificing clarity/organization.

Thanks, Taylor

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 68 of 120 in “odb: introduce `odb_for_each_object()`”
  1. 00/14 odb: introduce `odb_for_each_object()`Patrick Steinhardt, Jan 15, 2026
  2. 01/14 odb: rename `FOR_EACH_OBJECT_*` flagsPatrick Steinhardt, Jan 15, 2026
  3. Justin ToblerJan 15, 2026
  4. 02/14 odb: fix flags parameter to be unsignedPatrick Steinhardt, Jan 15, 2026
  5. 03/14 object-file: extract function to read object info from pathPatrick Steinhardt, Jan 15, 2026
  6. Justin ToblerJan 15, 2026
  7. Patrick SteinhardtJan 16, 2026
  8. Karthik NayakJan 20, 2026
  9. 04/14 object-file: introduce function to iterate through objectsPatrick Steinhardt, Jan 15, 2026
  10. Justin ToblerJan 15, 2026
  11. Patrick SteinhardtJan 16, 2026
  12. Karthik NayakJan 20, 2026
  13. 05/14 packfile: extract function to iterate through objects of a storePatrick Steinhardt, Jan 15, 2026
  14. 06/14 packfile: introduce function to iterate through objectsPatrick Steinhardt, Jan 15, 2026
  15. 07/14 odb: introduce `odb_for_each_object()`Patrick Steinhardt, Jan 15, 2026
  16. Justin ToblerJan 15, 2026
  17. Patrick SteinhardtJan 16, 2026
  18. Justin ToblerJan 16, 2026
  19. Patrick SteinhardtJan 19, 2026
  20. Karthik NayakJan 20, 2026
  21. Patrick SteinhardtJan 21, 2026
  22. 08/14 builtin/fsck: refactor to use `odb_for_each_object()`Patrick Steinhardt, Jan 15, 2026
  23. Justin ToblerJan 15, 2026
  24. 09/14 treewide: enumerate promisor objects via `odb_for_each_object()`Patrick Steinhardt, Jan 15, 2026
  25. 10/14 treewide: drop uses of `for_each_{loose,packed}_object()`Patrick Steinhardt, Jan 15, 2026
  26. Justin ToblerJan 15, 2026
  27. Patrick SteinhardtJan 16, 2026
  28. Justin ToblerJan 16, 2026
  29. Patrick SteinhardtJan 19, 2026
  30. 11/14 odb: introduce mtime fields for object info requestsPatrick Steinhardt, Jan 15, 2026
  31. 12/14 builtin/pack-objects: use `packfile_store_for_each_object()`Patrick Steinhardt, Jan 15, 2026
  32. 13/14 reachable: convert to use `odb_for_each_object()`Patrick Steinhardt, Jan 15, 2026
  33. 14/14 odb: drop unused `for_each_{loose,packed}_object()` functionsPatrick Steinhardt, Jan 15, 2026
  34. Junio C HamanoJan 15, 2026
  35. Patrick SteinhardtJan 16, 2026
  36. Junio C HamanoJan 16, 2026
  37. 00/14 odb: introduce `odb_for_each_object()`Patrick Steinhardt, Jan 20, 2026
  38. 01/14 odb: rename `FOR_EACH_OBJECT_*` flagsPatrick Steinhardt, Jan 20, 2026
  39. 02/14 odb: fix flags parameter to be unsignedPatrick Steinhardt, Jan 20, 2026
  40. 03/14 object-file: extract function to read object info from pathPatrick Steinhardt, Jan 20, 2026
  41. 04/14 object-file: introduce function to iterate through objectsPatrick Steinhardt, Jan 20, 2026
  42. 05/14 packfile: extract function to iterate through objects of a storePatrick Steinhardt, Jan 20, 2026
  43. 06/14 packfile: introduce function to iterate through objectsPatrick Steinhardt, Jan 20, 2026
  44. 07/14 odb: introduce `odb_for_each_object()`Patrick Steinhardt, Jan 20, 2026
  45. 08/14 builtin/fsck: refactor to use `odb_for_each_object()`Patrick Steinhardt, Jan 20, 2026
  46. 09/14 treewide: enumerate promisor objects via `odb_for_each_object()`Patrick Steinhardt, Jan 20, 2026
  47. 10/14 treewide: drop uses of `for_each_{loose,packed}_object()`Patrick Steinhardt, Jan 20, 2026
  48. 11/14 odb: introduce mtime fields for object info requestsPatrick Steinhardt, Jan 20, 2026
  49. 12/14 builtin/pack-objects: use `packfile_store_for_each_object()`Patrick Steinhardt, Jan 20, 2026
  50. 13/14 reachable: convert to use `odb_for_each_object()`Patrick Steinhardt, Jan 20, 2026
  51. 14/14 odb: drop unused `for_each_{loose,packed}_object()` functionsPatrick Steinhardt, Jan 20, 2026
  52. 00/14 odb: introduce `odb_for_each_object()`Patrick Steinhardt, Jan 21, 2026
  53. 01/14 odb: rename `FOR_EACH_OBJECT_*` flagsPatrick Steinhardt, Jan 21, 2026
  54. 02/14 odb: fix flags parameter to be unsignedPatrick Steinhardt, Jan 21, 2026
  55. Jeff KingJan 21, 2026
  56. Taylor BlauJan 22, 2026
  57. Junio C HamanoJan 22, 2026
  58. Jeff KingJan 22, 2026
  59. Patrick SteinhardtJan 23, 2026
  60. Junio C HamanoJan 26, 2026
  61. Patrick SteinhardtJan 22, 2026
  62. Taylor BlauJan 22, 2026
  63. 03/14 object-file: extract function to read object info from pathPatrick Steinhardt, Jan 21, 2026
  64. Taylor BlauJan 22, 2026
  65. Patrick SteinhardtJan 22, 2026
  66. Taylor BlauJan 22, 2026
  67. 04/14 object-file: introduce function to iterate through objectsPatrick Steinhardt, Jan 21, 2026
  68. Taylor BlauJan 22, 2026
  69. Patrick SteinhardtJan 22, 2026
  70. Taylor BlauJan 23, 2026
  71. 05/14 packfile: extract function to iterate through objects of a storePatrick Steinhardt, Jan 21, 2026
  72. Taylor BlauJan 22, 2026
  73. 06/14 packfile: introduce function to iterate through objectsPatrick Steinhardt, Jan 21, 2026
  74. Taylor BlauJan 23, 2026
  75. Patrick SteinhardtJan 23, 2026
  76. Chris TorekJan 23, 2026
  77. Junio C HamanoJan 23, 2026
  78. Taylor BlauJan 23, 2026
  79. 07/14 odb: introduce `odb_for_each_object()`Patrick Steinhardt, Jan 21, 2026
  80. Taylor BlauJan 23, 2026
  81. 08/14 builtin/fsck: refactor to use `odb_for_each_object()`Patrick Steinhardt, Jan 21, 2026
  82. Taylor BlauJan 23, 2026
  83. Patrick SteinhardtJan 23, 2026
  84. 09/14 treewide: enumerate promisor objects via `odb_for_each_object()`Patrick Steinhardt, Jan 21, 2026
  85. Taylor BlauJan 23, 2026
  86. 10/14 treewide: drop uses of `for_each_{loose,packed}_object()`Patrick Steinhardt, Jan 21, 2026
  87. Taylor BlauJan 23, 2026
  88. Patrick SteinhardtJan 23, 2026
  89. 11/14 odb: introduce mtime fields for object info requestsPatrick Steinhardt, Jan 21, 2026
  90. Taylor BlauJan 23, 2026
  91. Patrick SteinhardtJan 23, 2026
  92. Taylor BlauJan 23, 2026
  93. Patrick SteinhardtJan 26, 2026
  94. 12/14 builtin/pack-objects: use `packfile_store_for_each_object()`Patrick Steinhardt, Jan 21, 2026
  95. Taylor BlauJan 23, 2026
  96. Patrick SteinhardtJan 23, 2026
  97. Taylor BlauJan 23, 2026
  98. Patrick SteinhardtJan 26, 2026
  99. Jeff KingJan 29, 2026
  100. Patrick SteinhardtJan 30, 2026
  101. 13/14 reachable: convert to use `odb_for_each_object()`Patrick Steinhardt, Jan 21, 2026
  102. 14/14 odb: drop unused `for_each_{loose,packed}_object()` functionsPatrick Steinhardt, Jan 21, 2026
  103. Taylor BlauJan 22, 2026
  104. Junio C HamanoJan 22, 2026
  105. 00/14 odb: introduce `odb_for_each_object()`Patrick Steinhardt, Jan 26, 2026
  106. 01/14 odb: rename `FOR_EACH_OBJECT_*` flagsPatrick Steinhardt, Jan 26, 2026
  107. 02/14 odb: fix flags parameter to be unsignedPatrick Steinhardt, Jan 26, 2026
  108. 03/14 object-file: extract function to read object info from pathPatrick Steinhardt, Jan 26, 2026
  109. 04/14 object-file: introduce function to iterate through objectsPatrick Steinhardt, Jan 26, 2026
  110. 05/14 packfile: extract function to iterate through objects of a storePatrick Steinhardt, Jan 26, 2026
  111. 06/14 packfile: introduce function to iterate through objectsPatrick Steinhardt, Jan 26, 2026
  112. 07/14 odb: introduce `odb_for_each_object()`Patrick Steinhardt, Jan 26, 2026
  113. 08/14 builtin/fsck: refactor to use `odb_for_each_object()`Patrick Steinhardt, Jan 26, 2026
  114. 09/14 treewide: enumerate promisor objects via `odb_for_each_object()`Patrick Steinhardt, Jan 26, 2026
  115. 10/14 treewide: drop uses of `for_each_{loose,packed}_object()`Patrick Steinhardt, Jan 26, 2026
  116. 11/14 odb: introduce mtime fields for object info requestsPatrick Steinhardt, Jan 26, 2026
  117. 12/14 builtin/pack-objects: use `packfile_store_for_each_object()`Patrick Steinhardt, Jan 26, 2026
  118. 13/14 reachable: convert to use `odb_for_each_object()`Patrick Steinhardt, Jan 26, 2026
  119. 14/14 odb: drop unused `for_each_{loose,packed}_object()` functionsPatrick Steinhardt, Jan 26, 2026
  120. Junio C HamanoFeb 20, 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.