]> git.ipfire.org Git - thirdparty/git.git/commit
object-name: backend-generic `get_short_oid()`
authorPatrick Steinhardt <ps@pks.im>
Fri, 20 Mar 2026 07:07:34 +0000 (08:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2026 20:16:42 +0000 (13:16 -0700)
commiteac58debd9f61391a61b832e3cee349a20bd2c4a
treef99e6f89881bd890b928d0452d587fc4314601e9
parentd2612fe59e605102cb422fadbb0cb8bea499daee
object-name: backend-generic `get_short_oid()`

The function `get_short_oid()` takes as input an abbreviated object ID
and tries to turn that object ID into the full object ID. This is done
by iterating through all objects that have the user-provided prefix. If
that yields exactly one object we know that the abbreviated object ID is
unambiguous, otherwise it is ambiguous and we print the list of objects
that match the prefix.

We iterate through all objects with the given prefix by calling both
`find_short_packed_object()` and `find_short_object_filename()`, which
is of course specific to the "files" backend. But we now have a generic
way to iterate through objects with a specific prefix.

Refactor the code to use `odb_for_each_object()` instead so that it
works with object backends different than the "files" backend.

Remove the now-unused `find_short_packed_object()` function.

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