|
3 | 3 |
|
4 | 4 | #include "hashmap.h" |
5 | 5 | #include "object.h" |
6 | | -#include "odb/source.h" |
7 | 6 | #include "oidset.h" |
8 | 7 | #include "oidmap.h" |
9 | 8 | #include "string-list.h" |
|
12 | 11 | struct oidmap; |
13 | 12 | struct oidtree; |
14 | 13 | struct strbuf; |
| 14 | +struct strvec; |
15 | 15 | struct repository; |
16 | 16 | struct multi_pack_index; |
17 | 17 |
|
@@ -339,6 +339,42 @@ struct object_info { |
339 | 339 | */ |
340 | 340 | #define OBJECT_INFO_INIT { 0 } |
341 | 341 |
|
| 342 | +/* Flags that can be passed to `odb_read_object_info_extended()`. */ |
| 343 | +enum object_info_flags { |
| 344 | + /* Invoke lookup_replace_object() on the given hash. */ |
| 345 | + OBJECT_INFO_LOOKUP_REPLACE = (1 << 0), |
| 346 | + |
| 347 | + /* Do not reprepare object sources when the first lookup has failed. */ |
| 348 | + OBJECT_INFO_QUICK = (1 << 1), |
| 349 | + |
| 350 | + /* |
| 351 | + * Do not attempt to fetch the object if missing (even if fetch_is_missing is |
| 352 | + * nonzero). |
| 353 | + */ |
| 354 | + OBJECT_INFO_SKIP_FETCH_OBJECT = (1 << 2), |
| 355 | + |
| 356 | + /* Die if object corruption (not just an object being missing) was detected. */ |
| 357 | + OBJECT_INFO_DIE_IF_CORRUPT = (1 << 3), |
| 358 | + |
| 359 | + /* |
| 360 | + * We have already tried reading the object, but it couldn't be found |
| 361 | + * via any of the attached sources, and are now doing a second read. |
| 362 | + * This second read asks the individual sources to also evaluate |
| 363 | + * whether any on-disk state may have changed that may have caused the |
| 364 | + * object to appear. |
| 365 | + * |
| 366 | + * This flag is for internal use, only. The second read only occurs |
| 367 | + * when `OBJECT_INFO_QUICK` was not passed. |
| 368 | + */ |
| 369 | + OBJECT_INFO_SECOND_READ = (1 << 4), |
| 370 | + |
| 371 | + /* |
| 372 | + * This is meant for bulk prefetching of missing blobs in a partial |
| 373 | + * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK. |
| 374 | + */ |
| 375 | + OBJECT_INFO_FOR_PREFETCH = (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK), |
| 376 | +}; |
| 377 | + |
342 | 378 | /* |
343 | 379 | * Read object info from the object database and populate the `object_info` |
344 | 380 | * structure. Returns 0 on success, a negative error code otherwise. |
@@ -432,6 +468,18 @@ enum odb_for_each_object_flags { |
432 | 468 | ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4), |
433 | 469 | }; |
434 | 470 |
|
| 471 | +/* |
| 472 | + * A callback function that can be used to iterate through objects. If given, |
| 473 | + * the optional `oi` parameter will be populated the same as if you would call |
| 474 | + * `odb_read_object_info()`. |
| 475 | + * |
| 476 | + * Returning a non-zero error code will cause iteration to abort. The error |
| 477 | + * code will be propagated. |
| 478 | + */ |
| 479 | +typedef int (*odb_for_each_object_cb)(const struct object_id *oid, |
| 480 | + struct object_info *oi, |
| 481 | + void *cb_data); |
| 482 | + |
435 | 483 | /* |
436 | 484 | * Iterate through all objects contained in the object database. Note that |
437 | 485 | * objects may be iterated over multiple times in case they are either stored |
|
0 commit comments