object-store.h: move struct object_info from cache.h
Move struct object_info, and a few related #define's from cache.h to object-store.h. A surprising effect of this change is that replace-object.h, which includes object-store.h, now needs to directly include cache.h since that is where read_replace_refs is declared and that variable is used in one of its inline functions. The next commit will move that declaration and fix that unfortunate new direct inclusion of cache.h. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Feb 24, 2023 at 00:09 UTC
1c02840008b61676373f3703696dc0c07e6eff7d
4 files changed
+67
-65
merge-blobs.c
+1
-1
@@ -1,4 +1,4 @@
1
-#include "cache.h"
1
+#include "git-compat-util.h"
2
#include "run-command.h"
3
#include "xdiff-interface.h"
4
#include "ll-merge.h"
object-store.h
+64
-64
@@ -1,7 +1,7 @@
1
#ifndef OBJECT_STORE_H
2
#define OBJECT_STORE_H
3
4
-#include "cache.h"
4
+#include "object.h"
5
#include "oidmap.h"
6
#include "list.h"
7
#include "oid-array.h"
@@ -284,6 +284,69 @@ int pretend_object_file(void *, unsigned long, enum object_type,
284
285
int force_object_loose(const struct object_id *oid, time_t mtime);
286
287
+struct object_info {
288
+ /* Request */
289
+ enum object_type *typep;
290
+ unsigned long *sizep;
291
+ off_t *disk_sizep;
292
+ struct object_id *delta_base_oid;
293
+ struct strbuf *type_name;
294
+ void **contentp;
295
+
296
+ /* Response */
297
+ enum {
298
+ OI_CACHED,
299
+ OI_LOOSE,
300
+ OI_PACKED,
301
+ OI_DBCACHED
302
+ } whence;
303
+ union {
304
+ /*
305
+ * struct {
306
+ * ... Nothing to expose in this case
307
+ * } cached;
308
+ * struct {
309
+ * ... Nothing to expose in this case
310
+ * } loose;
311
+ */
312
+ struct {
313
+ struct packed_git *pack;
314
+ off_t offset;
315
+ unsigned int is_delta;
316
+ } packed;
317
+ } u;
318
+};
319
+
320
+/*
321
+ * Initializer for a "struct object_info" that wants no items. You may
322
+ * also memset() the memory to all-zeroes.
323
+ */
324
+#define OBJECT_INFO_INIT { 0 }
325
+
326
+/* Invoke lookup_replace_object() on the given hash */
327
+#define OBJECT_INFO_LOOKUP_REPLACE 1
328
+/* Allow reading from a loose object file of unknown/bogus type */
329
+#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2
330
+/* Do not retry packed storage after checking packed and loose storage */
331
+#define OBJECT_INFO_QUICK 8
332
+/*
333
+ * Do not attempt to fetch the object if missing (even if fetch_is_missing is
334
+ * nonzero).
335
+ */
336
+#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
337
+/*
338
+ * This is meant for bulk prefetching of missing blobs in a partial
339
+ * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
340
+ */
341
+#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
342
+
343
+/* Die if object corruption (not just an object being missing) was detected. */
344
+#define OBJECT_INFO_DIE_IF_CORRUPT 32
345
+
346
+int oid_object_info_extended(struct repository *r,
347
+ const struct object_id *,
348
+ struct object_info *, unsigned flags);
349
+
350
/*
351
* Open the loose object at path, check its hash, and return the contents,
352
* use the "oi" argument to assert things about the object, or e.g. populate its
@@ -381,69 +444,6 @@ static inline void obj_read_unlock(void)
444
pthread_mutex_unlock(&obj_read_mutex);
445
}
446
384
-struct object_info {
385
- /* Request */
386
- enum object_type *typep;
387
- unsigned long *sizep;
388
- off_t *disk_sizep;
389
- struct object_id *delta_base_oid;
390
- struct strbuf *type_name;
391
- void **contentp;
392
-
393
- /* Response */
394
- enum {
395
- OI_CACHED,
396
- OI_LOOSE,
397
- OI_PACKED,
398
- OI_DBCACHED
399
- } whence;
400
- union {
401
- /*
402
- * struct {
403
- * ... Nothing to expose in this case
404
- * } cached;
405
- * struct {
406
- * ... Nothing to expose in this case
407
- * } loose;
408
- */
409
- struct {
410
- struct packed_git *pack;
411
- off_t offset;
412
- unsigned int is_delta;
413
- } packed;
414
- } u;
415
-};
416
-
417
-/*
418
- * Initializer for a "struct object_info" that wants no items. You may
419
- * also memset() the memory to all-zeroes.
420
- */
421
-#define OBJECT_INFO_INIT { 0 }
422
-
423
-/* Invoke lookup_replace_object() on the given hash */
424
-#define OBJECT_INFO_LOOKUP_REPLACE 1
425
-/* Allow reading from a loose object file of unknown/bogus type */
426
-#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2
427
-/* Do not retry packed storage after checking packed and loose storage */
428
-#define OBJECT_INFO_QUICK 8
429
-/*
430
- * Do not attempt to fetch the object if missing (even if fetch_is_missing is
431
- * nonzero).
432
- */
433
-#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
434
-/*
435
- * This is meant for bulk prefetching of missing blobs in a partial
436
- * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
437
- */
438
-#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
439
-
440
-/* Die if object corruption (not just an object being missing) was detected. */
441
-#define OBJECT_INFO_DIE_IF_CORRUPT 32
442
-
443
-int oid_object_info_extended(struct repository *r,
444
- const struct object_id *,
445
- struct object_info *, unsigned flags);
446
-
447
/*
448
* Iterate over the files in the loose-object parts of the object
449
* directory "path", triggering the following callbacks:
protocol-caps.c
+1
@@ -5,6 +5,7 @@
5
#include "pkt-line.h"
6
#include "strvec.h"
7
#include "hash.h"
8
+#include "hex.h"
9
#include "object.h"
10
#include "object-store.h"
11
#include "string-list.h"
replace-object.h
+1
@@ -1,6 +1,7 @@
1
#ifndef REPLACE_OBJECT_H
2
#define REPLACE_OBJECT_H
3
4
+#include "cache.h"
5
#include "oidmap.h"
6
#include "repository.h"
7
#include "object-store.h"