aboutsummaryrefslogtreecommitdiff
path: root/odb.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-20 08:07:40 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-20 13:16:42 -0700
commit83869e15fa9ef3b0ea2adbfe2fe68a309f95b856 (patch)
tree40dd62b65441c70670cd5f019d11c88f9788e8ed /odb.h
parent6c2ede6e4abed754bb5891c2904212c05efcfb11 (diff)
downloadgit-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.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/odb.h b/odb.h
index e80fd8f7ab..984bafca9d 100644
--- a/odb.h
+++ b/odb.h
@@ -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