| Johannes Schindelin | 30415d5 | 2007-09-11 03:03:15 | [diff] [blame] | 1 | #ifndef BUNDLE_H |
| 2 | #define BUNDLE_H |
| 3 | |
| Jeff King | dbbcd44 | 2020-07-28 20:23:39 | [diff] [blame] | 4 | #include "strvec.h" |
| Ævar Arnfjörð Bjarmason | 10b635b | 2021-07-02 09:57:32 | [diff] [blame] | 5 | #include "string-list.h" |
| Derrick Stolee | 105c6f1 | 2022-03-09 16:01:39 | [diff] [blame] | 6 | #include "list-objects-filter-options.h" |
| Johannes Schindelin | 30415d5 | 2007-09-11 03:03:15 | [diff] [blame] | 7 | |
| 8 | struct bundle_header { |
| brian m. carlson | c5aecfc | 2020-07-29 23:14:20 | [diff] [blame] | 9 | unsigned version; |
| Ævar Arnfjörð Bjarmason | 10b635b | 2021-07-02 09:57:32 | [diff] [blame] | 10 | struct string_list prerequisites; |
| 11 | struct string_list references; |
| brian m. carlson | 6161ce7 | 2020-06-19 17:56:00 | [diff] [blame] | 12 | const struct git_hash_algo *hash_algo; |
| Derrick Stolee | 105c6f1 | 2022-03-09 16:01:39 | [diff] [blame] | 13 | struct list_objects_filter_options filter; |
| Johannes Schindelin | 30415d5 | 2007-09-11 03:03:15 | [diff] [blame] | 14 | }; |
| 15 | |
| Ævar Arnfjörð Bjarmason | 10b635b | 2021-07-02 09:57:32 | [diff] [blame] | 16 | #define BUNDLE_HEADER_INIT \ |
| 17 | { \ |
| 18 | .prerequisites = STRING_LIST_INIT_DUP, \ |
| 19 | .references = STRING_LIST_INIT_DUP, \ |
| Jeff King | 2a01bde | 2022-09-11 05:03:07 | [diff] [blame] | 20 | .filter = LIST_OBJECTS_FILTER_INIT, \ |
| Ævar Arnfjörð Bjarmason | 10b635b | 2021-07-02 09:57:32 | [diff] [blame] | 21 | } |
| 22 | void bundle_header_init(struct bundle_header *header); |
| 23 | void bundle_header_release(struct bundle_header *header); |
| 24 | |
| Junio C Hamano | 2727b71 | 2011-10-13 22:19:31 | [diff] [blame] | 25 | int is_bundle(const char *path, int quiet); |
| Johannes Schindelin | 30415d5 | 2007-09-11 03:03:15 | [diff] [blame] | 26 | int read_bundle_header(const char *path, struct bundle_header *header); |
| Ævar Arnfjörð Bjarmason | 89c6e45 | 2022-05-16 20:11:05 | [diff] [blame] | 27 | int read_bundle_header_fd(int fd, struct bundle_header *header, |
| 28 | const char *report_path); |
| Jeff King | fcb133e | 2019-01-24 13:11:51 | [diff] [blame] | 29 | int create_bundle(struct repository *r, const char *path, |
| Junio C Hamano | e0ad957 | 2020-08-12 01:04:11 | [diff] [blame] | 30 | int argc, const char **argv, struct strvec *pack_options, |
| brian m. carlson | c5aecfc | 2020-07-29 23:14:20 | [diff] [blame] | 31 | int version); |
| Derrick Stolee | 89bd7fe | 2022-10-12 12:52:37 | [diff] [blame] | 32 | |
| 33 | enum verify_bundle_flags { |
| 34 | VERIFY_BUNDLE_VERBOSE = (1 << 0), |
| Derrick Stolee | 70334fc | 2022-10-12 12:52:38 | [diff] [blame] | 35 | VERIFY_BUNDLE_QUIET = (1 << 1), |
| Derrick Stolee | 89bd7fe | 2022-10-12 12:52:37 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | int verify_bundle(struct repository *r, struct bundle_header *header, |
| 39 | enum verify_bundle_flags flags); |
| Ævar Arnfjörð Bjarmason | 0834257 | 2021-08-26 14:05:47 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Unbundle after reading the header with read_bundle_header(). |
| 43 | * |
| 44 | * We'll invoke "git index-pack --stdin --fix-thin" for you on the |
| 45 | * provided `bundle_fd` from read_bundle_header(). |
| Ævar Arnfjörð Bjarmason | 7366096 | 2021-09-05 07:34:43 | [diff] [blame] | 46 | * |
| 47 | * Provide "extra_index_pack_args" to pass any extra arguments |
| 48 | * (e.g. "-v" for verbose/progress), NULL otherwise. The provided |
| 49 | * "extra_index_pack_args" (if any) will be strvec_clear()'d for you. |
| Derrick Stolee | 89bd7fe | 2022-10-12 12:52:37 | [diff] [blame] | 50 | * |
| 51 | * Before unbundling, this method will call verify_bundle() with the |
| 52 | * given 'flags'. |
| Ævar Arnfjörð Bjarmason | 0834257 | 2021-08-26 14:05:47 | [diff] [blame] | 53 | */ |
| Nguyễn Thái Ngọc Duy | 74ae4b6 | 2018-11-10 05:49:01 | [diff] [blame] | 54 | int unbundle(struct repository *r, struct bundle_header *header, |
| Derrick Stolee | 89bd7fe | 2022-10-12 12:52:37 | [diff] [blame] | 55 | int bundle_fd, struct strvec *extra_index_pack_args, |
| 56 | enum verify_bundle_flags flags); |
| Johannes Schindelin | 30415d5 | 2007-09-11 03:03:15 | [diff] [blame] | 57 | int list_bundle_refs(struct bundle_header *header, |
| 58 | int argc, const char **argv); |
| 59 | |
| 60 | #endif |