12
ODB_SOURCE_FILES,
13
};
14
15
+/* Flags that can be passed to `odb_read_object_info_extended()`. */
16
+enum object_info_flags {
17
+ /* Invoke lookup_replace_object() on the given hash. */
18
+ OBJECT_INFO_LOOKUP_REPLACE = (1 << 0),
19
+
20
+ /* Do not reprepare object sources when the first lookup has failed. */
21
+ OBJECT_INFO_QUICK = (1 << 1),
22
+
23
+ /*
24
+ * Do not attempt to fetch the object if missing (even if fetch_is_missing is
25
+ * nonzero).
26
+ */
27
+ OBJECT_INFO_SKIP_FETCH_OBJECT = (1 << 2),
28
+
29
+ /* Die if object corruption (not just an object being missing) was detected. */
30
+ OBJECT_INFO_DIE_IF_CORRUPT = (1 << 3),
31
+
32
+ /*
33
+ * We have already tried reading the object, but it couldn't be found
34
+ * via any of the attached sources, and are now doing a second read.
35
+ * This second read asks the individual sources to also evaluate
36
+ * whether any on-disk state may have changed that may have caused the
37
+ * object to appear.
38
+ *
39
+ * This flag is for internal use, only. The second read only occurs
40
+ * when `OBJECT_INFO_QUICK` was not passed.
41
+ */
42
+ OBJECT_INFO_SECOND_READ = (1 << 4),
43
+
44
+ /*
45
+ * This is meant for bulk prefetching of missing blobs in a partial
46
+ * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK.
47
+ */
48
+ OBJECT_INFO_FOR_PREFETCH = (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK),
49
+};
50
+
51
+struct object_id;
52
+struct object_info;
53
+
54
/*
55
* The source is the part of the object database that stores the actual
56
* objects. It thus encapsulates the logic to read and write the specific
111
* example just been repacked so that new objects will become visible.
112
*/
113
void (*reprepare)(struct odb_source *source);
114
+
115
+ /*
116
+ * This callback is expected to read object information from the object
117
+ * database source. The object info will be partially populated with
118
+ * pointers for each bit of information that was requested by the
119
+ * caller.
120
+ *
121
+ * The flags field is a combination of `OBJECT_INFO` flags. Only the
122
+ * following fields need to be handled by the backend:
123
+ *
124
+ * - `OBJECT_INFO_QUICK` indicates it is fine to use caches without
125
+ * re-verifying the data.
126
+ *
127
+ * - `OBJECT_INFO_SECOND_READ` indicates that the initial object
128
+ * lookup has failed and that the object sources should check
129
+ * whether any of its on-disk state has changed that may have
130
+ * caused the object to appear. Sources are free to ignore the
131
+ * second read in case they know that the first read would have
132
+ * already surfaced the object without reloading any on-disk state.
133
+ *
134
+ * The callback is expected to return a negative error code in case
135
+ * reading the object has failed, 0 otherwise.
136
+ */
137
+ int (*read_object_info)(struct odb_source *source,
138
+ const struct object_id *oid,
139
+ struct object_info *oi,
140
+ enum object_info_flags flags);
141
};
142
143
/*
197
source->reprepare(source);
198
}
199
200
+/*
201
+ * Read an object from the object database source identified by its object ID.
202
+ * Returns 0 on success, a negative error code otherwise.
203
+ */
204
+static inline int odb_source_read_object_info(struct odb_source *source,
205
+ const struct object_id *oid,
206
+ struct object_info *oi,
207
+ enum object_info_flags flags)
208
+{
209
+ return source->read_object_info(source, oid, oi, flags);
210
+}
211
+
212
#endif