| Daniel Barkalow | 2d4177c | 2007-09-11 03:03:00 | [diff] [blame] | 1 | #ifndef FETCH_PACK_H |
| 2 | #define FETCH_PACK_H |
| 3 | |
| Michael Haggerty | 8bee93d | 2012-09-09 06:19:40 | [diff] [blame] | 4 | #include "string-list.h" |
| Brandon Williams | 685fbd3 | 2018-03-15 17:31:28 | [diff] [blame] | 5 | #include "protocol.h" |
| Jeff Hostetler | 640d8b7 | 2017-12-08 15:58:40 | [diff] [blame] | 6 | #include "list-objects-filter-options.h" |
| Jonathan Tan | 9c1e657 | 2021-05-04 21:16:01 | [diff] [blame] | 7 | #include "oidset.h" |
| Michael Haggerty | 8bee93d | 2012-09-09 06:19:40 | [diff] [blame] | 8 | |
| brian m. carlson | 910650d | 2017-03-31 01:40:00 | [diff] [blame] | 9 | struct oid_array; |
| Nguyễn Thái Ngọc Duy | beea415 | 2013-12-05 13:02:39 | [diff] [blame] | 10 | |
| Jonathan Nieder | 9cba13c | 2011-03-16 07:08:34 | [diff] [blame] | 11 | struct fetch_pack_args { |
| Daniel Barkalow | 2d4177c | 2007-09-11 03:03:00 | [diff] [blame] | 12 | const char *uploadpack; |
| Daniel Barkalow | 2d4177c | 2007-09-11 03:03:00 | [diff] [blame] | 13 | int unpacklimit; |
| Daniel Barkalow | 2d4177c | 2007-09-11 03:03:00 | [diff] [blame] | 14 | int depth; |
| Nguyễn Thái Ngọc Duy | 508ea88 | 2016-06-12 10:53:59 | [diff] [blame] | 15 | const char *deepen_since; |
| Nguyễn Thái Ngọc Duy | a45a260 | 2016-06-12 10:54:04 | [diff] [blame] | 16 | const struct string_list *deepen_not; |
| Jeff Hostetler | 640d8b7 | 2017-12-08 15:58:40 | [diff] [blame] | 17 | struct list_objects_filter_options filter_options; |
| Brandon Williams | 5e3548e | 2018-04-23 22:46:24 | [diff] [blame] | 18 | const struct string_list *server_options; |
| Jonathan Tan | 3390e42 | 2018-07-02 22:39:44 | [diff] [blame] | 19 | |
| 20 | /* |
| 21 | * If not NULL, during packfile negotiation, fetch-pack will send "have" |
| 22 | * lines only with these tips and their ancestors. |
| 23 | */ |
| 24 | const struct oid_array *negotiation_tips; |
| 25 | |
| Nguyễn Thái Ngọc Duy | cccf74e | 2016-06-12 10:54:09 | [diff] [blame] | 26 | unsigned deepen_relative:1; |
| Nguyễn Thái Ngọc Duy | f6486f0 | 2013-12-05 13:02:38 | [diff] [blame] | 27 | unsigned quiet:1; |
| 28 | unsigned keep_pack:1; |
| 29 | unsigned lock_pack:1; |
| 30 | unsigned use_thin_pack:1; |
| 31 | unsigned fetch_all:1; |
| 32 | unsigned stdin_refs:1; |
| Junio C Hamano | 92251b1 | 2014-01-17 20:21:14 | [diff] [blame] | 33 | unsigned diag_url:1; |
| Nguyễn Thái Ngọc Duy | f6486f0 | 2013-12-05 13:02:38 | [diff] [blame] | 34 | unsigned verbose:1; |
| 35 | unsigned no_progress:1; |
| 36 | unsigned include_tag:1; |
| 37 | unsigned stateless_rpc:1; |
| 38 | unsigned check_self_contained_and_connected:1; |
| 39 | unsigned self_contained_and_connected:1; |
| Nguyễn Thái Ngọc Duy | beea415 | 2013-12-05 13:02:39 | [diff] [blame] | 40 | unsigned cloning:1; |
| Nguyễn Thái Ngọc Duy | 48d25ca | 2013-12-05 13:02:42 | [diff] [blame] | 41 | unsigned update_shallow:1; |
| Li Linchao | 4fe788b | 2021-04-01 10:46:59 | [diff] [blame] | 42 | unsigned reject_shallow_remote:1; |
| Nguyễn Thái Ngọc Duy | 79891cb | 2016-06-12 10:53:56 | [diff] [blame] | 43 | unsigned deepen:1; |
| Robert Coup | 4dfd092 | 2022-03-28 14:02:06 | [diff] [blame] | 44 | unsigned refetch:1; |
| Jonathan Tan | 42d418d | 2020-08-17 19:48:18 | [diff] [blame] | 45 | |
| 46 | /* |
| 47 | * Indicate that the remote of this request is a promisor remote. The |
| 48 | * pack received does not need all referred-to objects to be present in |
| 49 | * the local object store, and fetch-pack will store the pack received |
| 50 | * together with a ".promisor" file indicating that the aforementioned |
| 51 | * pack is a promisor pack. |
| 52 | */ |
| Jonathan Tan | 88e2f9e | 2017-12-05 16:58:49 | [diff] [blame] | 53 | unsigned from_promisor:1; |
| 54 | |
| 55 | /* |
| Jonathan Tan | cf1e7c0 | 2018-07-02 22:08:43 | [diff] [blame] | 56 | * Because fetch_pack() overwrites the shallow file upon a |
| 57 | * successful deepening non-clone fetch, if this struct |
| 58 | * specifies such a fetch, fetch_pack() needs to perform a |
| 59 | * connectivity check before deciding if a fetch is successful |
| 60 | * (and overwriting the shallow file). fetch_pack() sets this |
| 61 | * field to 1 if such a connectivity check was performed. |
| 62 | * |
| 63 | * This is different from check_self_contained_and_connected |
| 64 | * in that the former allows existing objects in the |
| 65 | * repository to satisfy connectivity needs, whereas the |
| 66 | * latter doesn't. |
| 67 | */ |
| 68 | unsigned connectivity_checked:1; |
| Daniel Barkalow | 2d4177c | 2007-09-11 03:03:00 | [diff] [blame] | 69 | }; |
| 70 | |
| Michael Haggerty | 4ba1599 | 2012-09-09 06:19:43 | [diff] [blame] | 71 | /* |
| Junio C Hamano | f2db854 | 2013-01-29 22:02:15 | [diff] [blame] | 72 | * sought represents remote references that should be updated from. |
| 73 | * On return, the names that were found on the remote will have been |
| 74 | * marked as such. |
| Michael Haggerty | 4ba1599 | 2012-09-09 06:19:43 | [diff] [blame] | 75 | */ |
| Shawn O. Pearce | fa74052 | 2007-09-19 04:49:35 | [diff] [blame] | 76 | struct ref *fetch_pack(struct fetch_pack_args *args, |
| Jeff King | 0f804b0 | 2019-03-20 08:16:14 | [diff] [blame] | 77 | int fd[], |
| Michael Haggerty | 63c6945 | 2012-09-09 06:19:39 | [diff] [blame] | 78 | const struct ref *ref, |
| Junio C Hamano | f2db854 | 2013-01-29 22:02:15 | [diff] [blame] | 79 | struct ref **sought, |
| 80 | int nr_sought, |
| brian m. carlson | 910650d | 2017-03-31 01:40:00 | [diff] [blame] | 81 | struct oid_array *shallow, |
| Jonathan Tan | 9da69a6 | 2020-06-10 20:57:22 | [diff] [blame] | 82 | struct string_list *pack_lockfiles, |
| Brandon Williams | 685fbd3 | 2018-03-15 17:31:28 | [diff] [blame] | 83 | enum protocol_version version); |
| Daniel Barkalow | 2d4177c | 2007-09-11 03:03:00 | [diff] [blame] | 84 | |
| Matt McCutchen | e860d96 | 2017-02-22 16:01:22 | [diff] [blame] | 85 | /* |
| Jonathan Tan | 9c1e657 | 2021-05-04 21:16:01 | [diff] [blame] | 86 | * Execute the --negotiate-only mode of "git fetch", adding all known common |
| 87 | * commits to acked_commits. |
| 88 | * |
| 89 | * In the capability advertisement that has happened prior to invoking this |
| 90 | * function, the "wait-for-done" capability must be present. |
| 91 | */ |
| 92 | void negotiate_using_fetch(const struct oid_array *negotiation_tips, |
| 93 | const struct string_list *server_options, |
| 94 | int stateless_rpc, |
| 95 | int fd[], |
| 96 | struct oidset *acked_commits); |
| 97 | |
| 98 | /* |
| Matt McCutchen | e860d96 | 2017-02-22 16:01:22 | [diff] [blame] | 99 | * Print an appropriate error message for each sought ref that wasn't |
| 100 | * matched. Return 0 if all sought refs were matched, otherwise 1. |
| 101 | */ |
| 102 | int report_unmatched_refs(struct ref **sought, int nr_sought); |
| 103 | |
| Daniel Barkalow | 2d4177c | 2007-09-11 03:03:00 | [diff] [blame] | 104 | #endif |