Junio C Hamano | f96400c | 2011-09-02 16:33:22 -0700 | [diff] [blame] | 1 | #ifndef CONNECTED_H |
| 2 | #define CONNECTED_H |
| 3 | |
Elijah Newren | ef3ca95 | 2018-08-15 10:54:05 -0700 | [diff] [blame] | 4 | struct object_id; |
Nguyễn Thái Ngọc Duy | c6807a4 | 2013-05-26 08:16:17 +0700 | [diff] [blame] | 5 | struct transport; |
| 6 | |
Junio C Hamano | f96400c | 2011-09-02 16:33:22 -0700 | [diff] [blame] | 7 | /* |
| 8 | * Take callback data, and return next object name in the buffer. |
| 9 | * When called after returning the name for the last object, return -1 |
| 10 | * to signal EOF, otherwise return 0. |
| 11 | */ |
Patrick Steinhardt | 9fec7b2 | 2021-09-01 15:09:50 +0200 | [diff] [blame] | 12 | typedef const struct object_id *(*oid_iterate_fn)(void *); |
Junio C Hamano | f96400c | 2011-09-02 16:33:22 -0700 | [diff] [blame] | 13 | |
| 14 | /* |
Jeff King | 7043c70 | 2016-07-15 06:30:40 -0400 | [diff] [blame] | 15 | * Named-arguments struct for check_connected. All arguments are |
| 16 | * optional, and can be left to defaults as set by CHECK_CONNECTED_INIT. |
| 17 | */ |
| 18 | struct check_connected_options { |
| 19 | /* Avoid printing any errors to stderr. */ |
| 20 | int quiet; |
| 21 | |
| 22 | /* --shallow-file to pass to rev-list sub-process */ |
| 23 | const char *shallow_file; |
| 24 | |
| 25 | /* Transport whose objects we are checking, if available. */ |
| 26 | struct transport *transport; |
Jeff King | e033184 | 2016-07-15 06:32:03 -0400 | [diff] [blame] | 27 | |
| 28 | /* |
| 29 | * If non-zero, send error messages to this descriptor rather |
| 30 | * than stderr. The descriptor is closed before check_connected |
| 31 | * returns. |
| 32 | */ |
| 33 | int err_fd; |
Jeff King | 70d5e2d | 2016-07-15 06:32:28 -0400 | [diff] [blame] | 34 | |
| 35 | /* If non-zero, show progress as we traverse the objects. */ |
| 36 | int progress; |
Jeff King | 526f108 | 2016-10-03 16:49:08 -0400 | [diff] [blame] | 37 | |
| 38 | /* |
| 39 | * Insert these variables into the environment of the child process. |
| 40 | */ |
| 41 | const char **env; |
Jonathan Tan | cf1e7c0 | 2018-07-02 15:08:43 -0700 | [diff] [blame] | 42 | |
| 43 | /* |
| 44 | * If non-zero, check the ancestry chain completely, not stopping at |
| 45 | * any existing ref. This is necessary when deepening existing refs |
| 46 | * during a fetch. |
| 47 | */ |
| 48 | unsigned is_deepening_fetch : 1; |
Patrick Steinhardt | bcec678 | 2022-11-17 06:47:04 +0100 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * If not NULL, use `--exclude-hidden=$section` to exclude all refs |
| 52 | * hidden via the `$section.hideRefs` config from the set of |
| 53 | * already-reachable refs. |
| 54 | */ |
| 55 | const char *exclude_hidden_refs_section; |
Jeff King | 7043c70 | 2016-07-15 06:30:40 -0400 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #define CHECK_CONNECTED_INIT { 0 } |
| 59 | |
| 60 | /* |
Jonathan Tan | 4937291 | 2018-09-21 11:22:37 -0700 | [diff] [blame] | 61 | * Make sure that all given objects and all objects reachable from them |
| 62 | * either exist in our object store or (if the repository is a partial |
| 63 | * clone) are promised to be available. |
Junio C Hamano | f96400c | 2011-09-02 16:33:22 -0700 | [diff] [blame] | 64 | * |
| 65 | * Return 0 if Ok, non zero otherwise (i.e. some missing objects) |
Jeff King | 7043c70 | 2016-07-15 06:30:40 -0400 | [diff] [blame] | 66 | * |
| 67 | * If "opt" is NULL, behaves as if CHECK_CONNECTED_INIT was passed. |
Junio C Hamano | f96400c | 2011-09-02 16:33:22 -0700 | [diff] [blame] | 68 | */ |
brian m. carlson | 6ccac9e | 2017-10-15 22:06:54 +0000 | [diff] [blame] | 69 | int check_connected(oid_iterate_fn fn, void *cb_data, |
Jeff King | 7043c70 | 2016-07-15 06:30:40 -0400 | [diff] [blame] | 70 | struct check_connected_options *opt); |
Junio C Hamano | f96400c | 2011-09-02 16:33:22 -0700 | [diff] [blame] | 71 | |
| 72 | #endif /* CONNECTED_H */ |