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

[PATCH 00/14] odb: generic object name handling

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 19, 2026, 06:52 UTC
Message-ID
<20260319-b4-pks-odb-source-abbrev-v1-0-5ddebad292b0@pks.im>
Hi,

this patch series refactors handling of object names to become pluggable and thus generic. This includes:

  - Disambiguation of object names with a common prefix. This is
    required to list candidate objects in case the user has passed a
    non-unique prefix.
  - Abbreviating an object ID to the shortest prefix required while
    staying unique.

The logic to compute these operations is specific to the backend, but not generic. This patch series fixes that by moving the functionality into the respective backends.

This patch series may feel somewhat unexiting, but it's not. Especially abbreviating object IDs is done in lots of places, so this functionality is overall quite critical. So starting with this series, it is now possible to do all kinds of local work with an alternative backend: git-commit(1), git-log(1), git-rev-parse(1), git-merge(1) and many other commands now work as expected. My MongoDB proof of concept [1] only requires two commits (the object format extension) on top. And no, I don't endorse MongoDB or propose it as a future potential backend. It simply had a good C API that was easy to use.

Of course, other functionality, especially everything that involves packfiles, doesn't yet work.

This patch series is built on top of ca1db8a0f7 (The 17th batch, 2026-03-16) with ps/object-counting at 6801ffd37d (odb: introduce generic object counting, 2026-03-12) merged into it.

Thanks!
Patrick
[1]: https://gitlab.com/gitlab-org/git/-/merge_requests/454
---
Patrick Steinhardt (14):
      oidtree: modernize the code a bit
      oidtree: extend iteration to allow for arbitrary return codes
      odb: introduce `struct odb_for_each_object_options`
      object-name: move logic to iterate through loose prefixed objects
      object-name: move logic to iterate through packed prefixed objects
      object-name: extract function to parse object ID prefixes
      object-name: backend-generic `repo_collect_ambiguous()`
      object-name: backend-generic `get_short_oid()`
      object-name: merge `update_candidates()` and `match_prefix()`
      object-name: abbreviate loose object names without `disambiguate_state`
      object-name: simplify computing common prefixes
      object-name: move logic to compute loose abbreviation length
      object-file: move logic to compute packed abbreviation length
      odb: introduce generic `odb_find_abbrev_len()`
 builtin/cat-file.c       |   7 +-
 builtin/pack-objects.c   |  12 +-
 cbtree.c                 |  21 ++-
 cbtree.h                 |  11 +-
 commit-graph.c           |   5 +-
 hash.c                   |  18 ++
 hash.h                   |   3 +
 object-file.c            |  73 +++++++-
 object-file.h            |  21 ++-
 object-name.c            | 437 ++++++++---------------------------------------
 odb.c                    |  99 ++++++++++-
 odb.h                    |  39 +++++
 odb/source-files.c       |  33 +++-
 odb/source.h             |  30 +++-
 oidtree.c                |  65 +++----
 oidtree.h                |  48 +++++-
 packfile.c               | 297 +++++++++++++++++++++++++++++++-
 packfile.h               |   7 +-
 t/unit-tests/u-oidtree.c |  18 +-
 19 files changed, 774 insertions(+), 470 deletions(-)

--- base-commit: b052aca69d64d2d8e28e7ce97dcb1beb3d94515a change-id: 20260313-b4-pks-odb-source-abbrev-a84c51222bca

Next: Patrick Steinhardt
Message 1 of 52 in “odb: generic object name handling”
  1. 00/14 odb: generic object name handlingPatrick Steinhardt, Mar 19, 2026
  2. 01/14 oidtree: modernize the code a bitPatrick Steinhardt, Mar 19, 2026
  3. Junio C HamanoMar 19, 2026
  4. Patrick SteinhardtMar 20, 2026
  5. brian m. carlsonMar 20, 2026
  6. Patrick SteinhardtMar 23, 2026
  7. 02/14 oidtree: extend iteration to allow for arbitrary return codesPatrick Steinhardt, Mar 19, 2026
  8. Junio C HamanoMar 19, 2026
  9. Patrick SteinhardtMar 20, 2026
  10. Karthik NayakMar 19, 2026
  11. 03/14 odb: introduce `struct odb_for_each_object_options`Patrick Steinhardt, Mar 19, 2026
  12. Junio C HamanoMar 19, 2026
  13. Patrick SteinhardtMar 19, 2026
  14. Karthik NayakMar 20, 2026
  15. 04/14 object-name: move logic to iterate through loose prefixed objectsPatrick Steinhardt, Mar 19, 2026
  16. 05/14 object-name: move logic to iterate through packed prefixed objectsPatrick Steinhardt, Mar 19, 2026
  17. 06/14 object-name: extract function to parse object ID prefixesPatrick Steinhardt, Mar 19, 2026
  18. 07/14 object-name: backend-generic `repo_collect_ambiguous()`Patrick Steinhardt, Mar 19, 2026
  19. Junio C HamanoMar 19, 2026
  20. Patrick SteinhardtMar 19, 2026
  21. Karthik NayakMar 20, 2026
  22. 08/14 object-name: backend-generic `get_short_oid()`Patrick Steinhardt, Mar 19, 2026
  23. 09/14 object-name: merge `update_candidates()` and `match_prefix()`Patrick Steinhardt, Mar 19, 2026
  24. 10/14 object-name: abbreviate loose object names without `disambiguate_state`Patrick Steinhardt, Mar 19, 2026
  25. 11/14 object-name: simplify computing common prefixesPatrick Steinhardt, Mar 19, 2026
  26. Karthik NayakMar 20, 2026
  27. Patrick SteinhardtMar 20, 2026
  28. 12/14 object-name: move logic to compute loose abbreviation lengthPatrick Steinhardt, Mar 19, 2026
  29. 13/14 object-file: move logic to compute packed abbreviation lengthPatrick Steinhardt, Mar 19, 2026
  30. 14/14 odb: introduce generic `odb_find_abbrev_len()`Patrick Steinhardt, Mar 19, 2026
  31. 00/14 odb: generic object name handlingPatrick Steinhardt, Mar 20, 2026
  32. 01/14 oidtree: modernize the code a bitPatrick Steinhardt, Mar 20, 2026
  33. 02/14 oidtree: extend iteration to allow for arbitrary return codesPatrick Steinhardt, Mar 20, 2026
  34. 03/14 odb: introduce `struct odb_for_each_object_options`Patrick Steinhardt, Mar 20, 2026
  35. 04/14 object-name: move logic to iterate through loose prefixed objectsPatrick Steinhardt, Mar 20, 2026
  36. 05/14 object-name: move logic to iterate through packed prefixed objectsPatrick Steinhardt, Mar 20, 2026
  37. Toon ClaesMar 30, 2026
  38. 06/14 object-name: extract function to parse object ID prefixesPatrick Steinhardt, Mar 20, 2026
  39. 07/14 object-name: backend-generic `repo_collect_ambiguous()`Patrick Steinhardt, Mar 20, 2026
  40. 08/14 object-name: backend-generic `get_short_oid()`Patrick Steinhardt, Mar 20, 2026
  41. Toon ClaesMar 30, 2026
  42. 09/14 object-name: merge `update_candidates()` and `match_prefix()`Patrick Steinhardt, Mar 20, 2026
  43. 10/14 object-name: abbreviate loose object names without `disambiguate_state`Patrick Steinhardt, Mar 20, 2026
  44. 11/14 object-name: simplify computing common prefixesPatrick Steinhardt, Mar 20, 2026
  45. 12/14 object-name: move logic to compute loose abbreviation lengthPatrick Steinhardt, Mar 20, 2026
  46. 13/14 object-file: move logic to compute packed abbreviation lengthPatrick Steinhardt, Mar 20, 2026
  47. 14/14 odb: introduce generic `odb_find_abbrev_len()`Patrick Steinhardt, Mar 20, 2026
  48. Karthik NayakMar 20, 2026
  49. Patrick SteinhardtMar 20, 2026
  50. Toon ClaesMar 30, 2026
  51. Junio C HamanoMar 30, 2026
  52. Patrick SteinhardtMar 31, 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.