git
[Ported from github.com/git/git] Sync with Git 2.56.1
Brought by drakestapleton
| 1 | #ifndef ODB_SOURCE_LOOSE_H |
| 2 | #define ODB_SOURCE_LOOSE_H |
| 3 | |
| 4 | #include "odb/source.h" |
| 5 | |
| 6 | struct odb_source_files; |
| 7 | struct object_database; |
| 8 | struct oidtree; |
| 9 | |
| 10 | /* |
| 11 | * An object database source that stores its objects in loose format, one |
| 12 | * file per object. |
| 13 | */ |
| 14 | struct odb_source_loose { |
| 15 | struct odb_source base; |
| 16 | |
| 17 | /* |
| 18 | * Used to store the results of readdir(3) calls when we are OK |
| 19 | * sacrificing accuracy due to races for speed. That includes |
| 20 | * object existence with OBJECT_INFO_QUICK, as well as |
| 21 | * our search for unique abbreviated hashes. Don't use it for tasks |
| 22 | * requiring greater accuracy! |
| 23 | * |
| 24 | * Be sure to call odb_load_loose_cache() before using. |
| 25 | */ |
| 26 | uint32_t subdir_seen[8]; /* 256 bits */ |
| 27 | struct oidtree *cache; |
| 28 | |
| 29 | /* Map between object IDs for loose objects. */ |
| 30 | struct loose_object_map *map; |
| 31 | |
| 32 | /* Whether this is a source that will never be committed to disk. */ |
| 33 | int will_destroy; |
| 34 | }; |
| 35 | |
| 36 | struct odb_source_loose *odb_source_loose_new(struct object_database *odb, |
| 37 | const char *path); |
| 38 | |
| 39 | /* |
| 40 | * Cast the given object database source to the loose backend. This will cause |
| 41 | * a BUG in case the source doesn't use this backend. |
| 42 | */ |
| 43 | static inline struct odb_source_loose *odb_source_loose_downcast(struct odb_source *source) |
| 44 | { |
| 45 | if (source->type != ODB_SOURCE_LOOSE) |
| 46 | BUG("trying to downcast source of type '%s' to '%s'", |
| 47 | odb_source_type_to_name(source->type), |
| 48 | odb_source_type_to_name(ODB_SOURCE_LOOSE)); |
| 49 | return container_of(source, struct odb_source_loose, base); |
| 50 | } |
| 51 | |
| 52 | #endif |