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 * Fetch object info (only size currently) from remote without
50 * downloading the objects.
51 *
52 * Uses object-info capability of v2 protocol.
53 */
54 int (*fetch_object_info)(struct transport *transport);
55
56 /**
57 * Push the objects and refs. Send the necessary objects, and
58 * then, for any refs where peer_ref is set and
59 * peer_ref->new_oid is different from old_oid, tell the
60 * remote side to update each ref in the list from old_oid to
61 * peer_ref->new_oid.
62 *
63 * Where possible, set the status for each ref appropriately.
64 *
65 * The transport must modify new_sha1 in the ref to the new
66 * value if the remote accepted the change. Note that this
67 * could be a different value from peer_ref->new_oid if the
68 * process involved generating new commits.
69 **/
70 int (*push_refs)(struct transport *transport, struct ref *refs, int flags);
71 int (*connect)(struct transport *connection,
72 enum git_connect_service service,
73 const char *executable, int fd[2]);
74
75 /** get_refs_list(), fetch(), and push_refs() can keep
76 * resources (such as a connection) reserved for further
77 * use. disconnect() releases these resources.
78 **/
79 int (*disconnect)(struct transport *connection);
80 };
81
82 #endif