aboutsummaryrefslogtreecommitdiff
path: root/odb/source.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-05 15:19:52 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-05 11:45:16 -0800
commit6a38b13fbac73d1a1982f9211c5c3e64e1191696 (patch)
tree5476c9e8b1b91e9189384d434676ea906be52d8e /odb/source.h
parentfdefdc2e6979e9e8cb28b34c458f42b44f217bf0 (diff)
downloadgit-6a38b13fbac73d1a1982f9211c5c3e64e1191696.tar.xz
odb/source: make `freshen_object()` function pluggable
Introduce a new callback function in `struct odb_source` to make the function pluggable. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'odb/source.h')
-rw-r--r--odb/source.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/odb/source.h b/odb/source.h
index be56995389..7f2ecf420b 100644
--- a/odb/source.h
+++ b/odb/source.h
@@ -186,6 +186,18 @@ struct odb_source {
odb_for_each_object_cb cb,
void *cb_data,
unsigned flags);
+
+ /*
+ * 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
+ * they were unreachable.
+ *
+ * Returns 0 in case the object does not exist, 1 in case the object
+ * has been freshened.
+ */
+ int (*freshen_object)(struct odb_source *source,
+ const struct object_id *oid);
};
/*
@@ -297,4 +309,15 @@ static inline int odb_source_for_each_object(struct odb_source *source,
return source->for_each_object(source, request, cb, cb_data, flags);
}
+/*
+ * 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.
+ */
+static inline int odb_source_freshen_object(struct odb_source *source,
+ const struct object_id *oid)
+{
+ return source->freshen_object(source, oid);
+}
+
#endif