]> Kevux Git Server - rit/commit
object-name: abbreviate loose object names without `disambiguate_state`
authorPatrick Steinhardt <ps@pks.im>
Fri, 20 Mar 2026 07:07:36 +0000 (08:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2026 20:16:42 +0000 (13:16 -0700)
commit67f47eab61c3a2c14f2d0351c3844f12fbd95dd2
treef3dce10b05594045a6aa3f34a816e70991e02022
parente9b7caa1b14bc1fe825b216941a0655d6afdffe5
object-name: abbreviate loose object names without `disambiguate_state`

The function `find_short_object_filename()` takes an object ID and
computes the minimum required object name length to make it unique. This
is done by reusing the object disambiguation infrastructure, where we
iterate through every loose object and then update the disambiguate
state one by one.

Ultimately, we don't care about the disambiguate state though. It is
used because this infrastructure knows how to enumerate only those
objects that match a given prefix. But now that we have extended the
`odb_for_each_object()` function to do this for us we have an easier way
to do this. Consequently, we really only use the disambiguate state now
to propagate `struct min_abbrev_data`.

Refactor the code and drop this indirection so that we use `struct
min_abbrev_data` directly. This also allows us to drop some now-unused
logic from the disambiguate infrastructure.

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