diff options
| author | Patrick Steinhardt <ps@pks.im> | 2026-03-20 08:07:40 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-20 13:16:42 -0700 |
| commit | 83869e15fa9ef3b0ea2adbfe2fe68a309f95b856 (patch) | |
| tree | 40dd62b65441c70670cd5f019d11c88f9788e8ed /odb.h | |
| parent | 6c2ede6e4abed754bb5891c2904212c05efcfb11 (diff) | |
| download | git-83869e15fa9ef3b0ea2adbfe2fe68a309f95b856.tar.xz | |
odb: introduce generic `odb_find_abbrev_len()`
Introduce a new generic `odb_find_abbrev_len()` function as well as
source-specific callback functions. This makes the logic to compute the
required prefix length to make a given object unique fully pluggable.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'odb.h')
| -rw-r--r-- | odb.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -545,6 +545,22 @@ int odb_count_objects(struct object_database *odb, enum odb_count_objects_flags flags, unsigned long *out); +/* + * Given an object ID, find the minimum required length required to make the + * object ID unique across the whole object database. + * + * The `min_len` determines the minimum abbreviated length that'll be returned + * by this function. If `min_len < 0`, then the function will set a sensible + * default minimum abbreviation length. + * + * Returns 0 on success, a negative error code otherwise. The computed length + * will be assigned to `*out`. + */ +int odb_find_abbrev_len(struct object_database *odb, + const struct object_id *oid, + int min_len, + unsigned *out); + enum { /* * By default, `odb_write_object()` does not actually write anything |
