Raw
1 #ifndef PROMISOR_REMOTE_H
2 #define PROMISOR_REMOTE_H
3
4 #include "repository.h"
5
6 struct object_id;
7
8 /*
9 * Promisor remote linked list
10 *
11 * Information in its fields come from remote.XXX config entries or
12 * from extensions.partialclone, except for 'accepted' which comes
13 * from protocol v2 capabilities exchange.
14 */
15 struct promisor_remote {
16 struct promisor_remote *next;
17 char *partial_clone_filter;
18 char *advertised_filter;
19 unsigned int accepted : 1;
20 const char name[FLEX_ARRAY];
21 };
22
23 void repo_promisor_remote_reinit(struct repository *r);
24 void promisor_remote_clear(struct promisor_remote_config *config);
25 struct promisor_remote *repo_promisor_remote_find(struct repository *r, const char *remote_name);
26 int repo_has_promisor_remote(struct repository *r);
27
28 /*
29 * Fetches all requested objects from all promisor remotes, trying them one at
30 * a time until all objects are fetched.
31 *
32 * Callers are responsible for filtering out OIDs that are already present
33 * locally before calling this function: every supplied OID is sent in the
34 * fetch request, even if the object already exists in the local object
35 * store. (Only after a fetch failure does this function fall back to
36 * stripping already-present OIDs from the list before trying the next
37 * configured promisor remote.) Callers should also deduplicate the OIDs.
38 *
39 * To test for local presence without triggering a lazy fetch (which would
40 * defeat the purpose of batching), use odb_has_object(..., 0) or
41 * odb_read_object_info_extended() with OBJECT_INFO_FOR_PREFETCH.
42 *
43 * If oid_nr is 0, this function returns immediately.
44 */
45 void promisor_remote_get_direct(struct repository *repo,
46 const struct object_id *oids,
47 int oid_nr);
48
49 /*
50 * Prepare a "promisor-remote" advertisement by a server.
51 * Check the value of "promisor.advertise" and maybe the configured
52 * promisor remotes, if any, to prepare information to send in an
53 * advertisement.
54 * Return value is NULL if no promisor remote advertisement should be
55 * made. Otherwise it contains the names and urls of the advertised
56 * promisor remotes separated by ';'. See gitprotocol-v2(5).
57 */
58 char *promisor_remote_info(struct repository *repo);
59
60 /*
61 * Prepare a reply to a "promisor-remote" advertisement from a server.
62 * Check the value of "promisor.acceptfromserver" and maybe the
63 * configured promisor remotes, if any, to prepare the reply. If the
64 * `accepted_out` argument is not NULL, it is set to either NULL or to
65 * the names of the accepted promisor remotes separated by ';' if
66 * any. See gitprotocol-v2(5).
67 */
68 void promisor_remote_reply(const char *info, char **accepted_out);
69
70 /*
71 * Set the 'accepted' flag for some promisor remotes. Useful on the
72 * server side when some promisor remotes have been accepted by the
73 * client.
74 */
75 void mark_promisor_remotes_as_accepted(struct repository *repo, const char *remotes);
76
77 /*
78 * Has any promisor remote been accepted by the client?
79 */
80 int repo_has_accepted_promisor_remote(struct repository *r);
81
82 /*
83 * Use the filters from the accepted remotes to create a combined
84 * filter (useful in `--filter=auto` mode).
85 */
86 char *promisor_remote_construct_filter(struct repository *repo);
87
88 #endif /* PROMISOR_REMOTE_H */