Raw
1 #ifndef TRANSPORT_INTERNAL_H
2 #define TRANSPORT_INTERNAL_H
3
4 #include "connect.h"
5
6 struct ref;
7 struct transport;
8 struct strvec;
9 struct transport_ls_refs_options;
10
11 struct transport_vtable {
12 /**
13 * Returns 0 if successful, positive if the option is not
14 * recognized or is inapplicable, and negative if the option
15 * is applicable but the value is invalid.
16 **/
17 int (*set_option)(struct transport *connection, const char *name,
18 const char *value);
19 /**
20 * Returns a list of the remote side's refs. In order to allow
21 * the transport to try to share connections, for_push is a
22 * hint as to whether the ultimate operation is a push or a fetch.
23 *
24 * If the transport is able to determine the remote hash for
25 * the ref without a huge amount of effort, it should store it
26 * in the ref's old_sha1 field; otherwise it should be all 0.
27 **/
28 struct ref *(*get_refs_list)(struct transport *transport, int for_push,
29 struct transport_ls_refs_options *transport_options);
30
31 /**
32 * Populates the remote side's bundle-uri under protocol v2,
33 * if the "bundle-uri" capability was advertised. Returns 0 if
34 * OK, negative values on error.
35 */
36 int (*get_bundle_uri)(struct transport *transport);
37
38 /**
39 * Fetch the objects for the given refs. Note that this gets
40 * an array, and should ignore the list structure.
41 *
42 * If the transport did not get hashes for refs in
43 * get_refs_list(), it should set the old_sha1 fields in the
44 * provided refs now.
45 **/
46 int (*fetch_refs)(struct transport *transport, int refs_nr, struct ref **refs);
47
48 /**
49 * Push the objects and refs. Send the necessary objects, and
50 * then, for any refs where peer_ref is set and
51 * peer_ref->new_oid is different from old_oid, tell the
52 * remote side to update each ref in the list from old_oid to
53 * peer_ref->new_oid.
54 *
55 * Where possible, set the status for each ref appropriately.
56 *
57 * The transport must modify new_sha1 in the ref to the new
58 * value if the remote accepted the change. Note that this
59 * could be a different value from peer_ref->new_oid if the
60 * process involved generating new commits.
61 **/
62 int (*push_refs)(struct transport *transport, struct ref *refs, int flags);
63 int (*connect)(struct transport *connection,
64 enum git_connect_service service,
65 const char *executable, int fd[2]);
66
67 /** get_refs_list(), fetch(), and push_refs() can keep
68 * resources (such as a connection) reserved for further
69 * use. disconnect() releases these resources.
70 **/
71 int (*disconnect)(struct transport *connection);
72 };
73
74 #endif