aboutsummaryrefslogtreecommitdiff
path: root/odb/source.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-04-06 15:42:48 -0700
committerJunio C Hamano <gitster@pobox.com>2026-04-06 15:42:49 -0700
commitd75badf83bc3fc8e47413970874bac681eeb5bbe (patch)
tree081e6d6ef91541664ae664acc0af7f8e7f943d01 /odb/source.h
parent2f8c3f6a5a6d6a3de205be709e1a598b9d4b0b3e (diff)
parent83869e15fa9ef3b0ea2adbfe2fe68a309f95b856 (diff)
downloadgit-d75badf83bc3fc8e47413970874bac681eeb5bbe.tar.xz
Merge branch 'ps/odb-generic-object-name-handling'
Object name handling (disambiguation and abbreviation) has been refactored to be backend-generic, moving logic into the respective object database backends. * ps/odb-generic-object-name-handling: odb: introduce generic `odb_find_abbrev_len()` object-file: move logic to compute packed abbreviation length object-name: move logic to compute loose abbreviation length object-name: simplify computing common prefixes object-name: abbreviate loose object names without `disambiguate_state` object-name: merge `update_candidates()` and `match_prefix()` object-name: backend-generic `get_short_oid()` object-name: backend-generic `repo_collect_ambiguous()` object-name: extract function to parse object ID prefixes object-name: move logic to iterate through packed prefixed objects object-name: move logic to iterate through loose prefixed objects odb: introduce `struct odb_for_each_object_options` oidtree: extend iteration to allow for arbitrary return codes oidtree: modernize the code a bit object-file: fix sparse 'plain integer as NULL pointer' error
Diffstat (limited to 'odb/source.h')
-rw-r--r--odb/source.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/odb/source.h b/odb/source.h
index 96c906e7a1..a9d7d0b96f 100644
--- a/odb/source.h
+++ b/odb/source.h
@@ -140,7 +140,7 @@ struct odb_source {
const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
- unsigned flags);
+ const struct odb_for_each_object_options *opts);
/*
* This callback is expected to count objects in the given object
@@ -158,6 +158,18 @@ struct odb_source {
unsigned long *out);
/*
+ * This callback is expected to find the minimum required length to
+ * make the given object ID unique.
+ *
+ * The callback is expected to return a negative error code in case it
+ * failed, 0 otherwise.
+ */
+ int (*find_abbrev_len)(struct odb_source *source,
+ const struct object_id *oid,
+ unsigned min_length,
+ unsigned *out);
+
+ /*
* This callback is expected to freshen the given object so that its
* last access time is set to the current time. This is used to ensure
* that objects that are recent will not get garbage collected even if
@@ -343,9 +355,9 @@ static inline int odb_source_for_each_object(struct odb_source *source,
const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
- unsigned flags)
+ const struct odb_for_each_object_options *opts)
{
- return source->for_each_object(source, request, cb, cb_data, flags);
+ return source->for_each_object(source, request, cb, cb_data, opts);
}
/*
@@ -361,6 +373,18 @@ static inline int odb_source_count_objects(struct odb_source *source,
}
/*
+ * Determine the minimum required length to make the given object ID unique in
+ * the given source. Returns 0 on success, a negative error code otherwise.
+ */
+static inline int odb_source_find_abbrev_len(struct odb_source *source,
+ const struct object_id *oid,
+ unsigned min_len,
+ unsigned *out)
+{
+ return source->find_abbrev_len(source, oid, min_len, out);
+}
+
+/*
* Freshen an object in the object database by updating its timestamp.
* Returns 1 in case the object has been freshened, 0 in case the object does
* not exist.