]>
Commit | Line | Data |
---|---|---|
e967ca38 JT |
1 | #ifndef TRANSPORT_INTERNAL_H |
2 | #define TRANSPORT_INTERNAL_H | |
3 | ||
4 | struct ref; | |
5 | struct transport; | |
873cd28a | 6 | struct strvec; |
e967ca38 JT |
7 | |
8 | struct transport_vtable { | |
9 | /** | |
10 | * Returns 0 if successful, positive if the option is not | |
11 | * recognized or is inapplicable, and negative if the option | |
12 | * is applicable but the value is invalid. | |
13 | **/ | |
14 | int (*set_option)(struct transport *connection, const char *name, | |
15 | const char *value); | |
16 | /** | |
17 | * Returns a list of the remote side's refs. In order to allow | |
18 | * the transport to try to share connections, for_push is a | |
19 | * hint as to whether the ultimate operation is a push or a fetch. | |
20 | * | |
834cf34b BW |
21 | * If communicating using protocol v2 a list of prefixes can be |
22 | * provided to be sent to the server to enable it to limit the ref | |
23 | * advertisement. Since ref filtering is done on the server's end, and | |
24 | * only when using protocol v2, this list will be ignored when not | |
25 | * using protocol v2 meaning this function can return refs which don't | |
26 | * match the provided ref_prefixes. | |
27 | * | |
e967ca38 JT |
28 | * If the transport is able to determine the remote hash for |
29 | * the ref without a huge amount of effort, it should store it | |
30 | * in the ref's old_sha1 field; otherwise it should be all 0. | |
31 | **/ | |
834cf34b | 32 | struct ref *(*get_refs_list)(struct transport *transport, int for_push, |
c972bf4c | 33 | const struct strvec *ref_prefixes); |
e967ca38 JT |
34 | |
35 | /** | |
36 | * Fetch the objects for the given refs. Note that this gets | |
37 | * an array, and should ignore the list structure. | |
38 | * | |
39 | * If the transport did not get hashes for refs in | |
40 | * get_refs_list(), it should set the old_sha1 fields in the | |
41 | * provided refs now. | |
42 | **/ | |
e2842b39 | 43 | int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs); |
e967ca38 JT |
44 | |
45 | /** | |
46 | * Push the objects and refs. Send the necessary objects, and | |
47 | * then, for any refs where peer_ref is set and | |
48 | * peer_ref->new_oid is different from old_oid, tell the | |
49 | * remote side to update each ref in the list from old_oid to | |
50 | * peer_ref->new_oid. | |
51 | * | |
52 | * Where possible, set the status for each ref appropriately. | |
53 | * | |
54 | * The transport must modify new_sha1 in the ref to the new | |
55 | * value if the remote accepted the change. Note that this | |
56 | * could be a different value from peer_ref->new_oid if the | |
57 | * process involved generating new commits. | |
58 | **/ | |
59 | int (*push_refs)(struct transport *transport, struct ref *refs, int flags); | |
60 | int (*connect)(struct transport *connection, const char *name, | |
61 | const char *executable, int fd[2]); | |
62 | ||
63 | /** get_refs_list(), fetch(), and push_refs() can keep | |
64 | * resources (such as a connection) reserved for further | |
65 | * use. disconnect() releases these resources. | |
66 | **/ | |
67 | int (*disconnect)(struct transport *connection); | |
68 | }; | |
69 | ||
70 | #endif |