12 * The remote_bundle_info struct contains information for a single bundle
13 * URI. This may be initialized simply by a given URI or might have
14 * additional metadata associated with it if the bundle was advertised by
17 struct remote_bundle_info
{
18 struct hashmap_entry ent
;
21 * The 'id' is a name given to the bundle for reference
22 * by other bundle infos.
27 * The 'uri' is the location of the remote bundle so
28 * it can be downloaded on-demand. This will be NULL
29 * if there was no table of contents.
34 * If the bundle has been downloaded, then 'file' is a
35 * filename storing its contents. Otherwise, 'file' is
41 * If the bundle has been unbundled successfully, then
42 * this boolean is true.
47 * If the bundle is part of a list with the creationToken
48 * heuristic, then we use this member for sorting the bundles.
50 uint64_t creationToken
;
53 #define REMOTE_BUNDLE_INFO_INIT { 0 }
55 enum bundle_list_mode
{
61 enum bundle_list_heuristic
{
62 BUNDLE_HEURISTIC_NONE
= 0,
63 BUNDLE_HEURISTIC_CREATIONTOKEN
,
66 BUNDLE_HEURISTIC__COUNT
70 * A bundle_list contains an unordered set of remote_bundle_info structs,
71 * as well as information about the bundle listing, such as version and
76 enum bundle_list_mode mode
;
77 struct hashmap bundles
;
80 * The baseURI of a bundle_list is the URI that provided the list.
82 * In the case of the 'bundle-uri' protocol v2 command, the base
83 * URI is the URI of the Git remote.
85 * Otherwise, the bundle list was downloaded over HTTP from some
86 * known URI. 'baseURI' is set to that value.
88 * The baseURI is used as the base for any relative URIs
89 * advertised by the bundle list at that location.
94 * A list can have a heuristic, which helps reduce the number of
97 enum bundle_list_heuristic heuristic
;
100 void init_bundle_list(struct bundle_list
*list
);
101 void clear_bundle_list(struct bundle_list
*list
);
103 typedef int (*bundle_iterator
)(struct remote_bundle_info
*bundle
,
106 int for_all_bundles_in_list(struct bundle_list
*list
,
107 bundle_iterator iter
,
111 void print_bundle_list(FILE *fp
, struct bundle_list
*list
);
114 * A bundle URI may point to a bundle list where the key=value
115 * pairs are provided in config file format. This method is
116 * exposed publicly for testing purposes.
118 int bundle_uri_parse_config_format(const char *uri
,
119 const char *filename
,
120 struct bundle_list
*list
);
123 * Fetch data from the given 'uri' and unbundle the bundle data found
124 * based on that information.
126 * Returns non-zero if no bundle information is found at the given 'uri'.
128 * If the pointer 'has_heuristic' is non-NULL, then the value it points to
129 * will be set to be non-zero if and only if the fetched list has a
130 * heuristic value. Such a value indicates that the list was designed for
131 * incremental fetches.
133 int fetch_bundle_uri(struct repository
*r
, const char *uri
,
137 * Given a bundle list that was already advertised (likely by the
138 * bundle-uri protocol v2 verb) at the given uri, fetch and unbundle the
139 * bundles according to the bundle strategy of that list.
141 * It is expected that the given 'list' is initialized, including its
144 * Returns non-zero if there was an error trying to download the list
145 * or any of its advertised bundles.
147 int fetch_bundle_list(struct repository
*r
,
148 struct bundle_list
*list
);
153 int bundle_uri_advertise(struct repository
*r
, struct strbuf
*value
);
154 int bundle_uri_command(struct repository
*r
, struct packet_reader
*request
);
157 * General API for {transport,connect}.c etc.
161 * Parse a "key=value" packet line from the bundle-uri verb.
163 * Returns 0 on success and non-zero on error.
165 int bundle_uri_parse_line(struct bundle_list
*list
,