| 1 | #ifndef ODB_SOURCE_FILES_H |
| 2 | #define ODB_SOURCE_FILES_H |
| 3 | |
| 4 | #include "odb/source.h" |
| 5 | |
| 6 | struct odb_source_loose; |
| 7 | struct packfile_store; |
| 8 | |
| 9 | /* |
| 10 | * The files object database source uses a combination of loose objects and |
| 11 | * packfiles. It is the default backend used by Git to store objects. |
| 12 | */ |
| 13 | struct odb_source_files { |
| 14 | struct odb_source base; |
| 15 | struct odb_source_loose *loose; |
| 16 | struct packfile_store *packed; |
| 17 | }; |
| 18 | |
| 19 | /* Allocate and initialize a new object source. */ |
| 20 | struct odb_source_files *odb_source_files_new(struct object_database *odb, |
| 21 | const char *path, |
| 22 | bool local); |
| 23 | |
| 24 | /* |
| 25 | * Cast the given object database source to the files backend. This will cause |
| 26 | * a BUG in case the source doesn't use this backend. |
| 27 | */ |
| 28 | static inline struct odb_source_files *odb_source_files_downcast(struct odb_source *source) |
| 29 | { |
| 30 | if (source->type != ODB_SOURCE_FILES) |
| 31 | BUG("trying to downcast source of type '%d' to files", source->type); |
| 32 | return container_of(source, struct odb_source_files, base); |
| 33 | } |
| 34 | |
| 35 | #endif |