summaryrefslogtreecommitdiff
path: root/transport.h
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-12-14 21:44:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-14 22:28:04 (GMT)
commite967ca38473a05abf3e8f7a025c6b9bee487aa4f (patch)
tree1954c9a0a80d1f44f9e5d5c2a75d042f7591b99d /transport.h
parent245abe34ac0622b349470b89d4b76a082a133cab (diff)
downloadgit-e967ca38473a05abf3e8f7a025c6b9bee487aa4f.zip
git-e967ca38473a05abf3e8f7a025c6b9bee487aa4f.tar.gz
git-e967ca38473a05abf3e8f7a025c6b9bee487aa4f.tar.bz2
transport: make transport vtable more private
Move the definition of the transport-specific functions provided by transports, whether declared in transport.c or transport-helper.c, into an internal header. This means that transport-using code (as opposed to transport-declaring code) can no longer access these functions (without importing the internal header themselves), making it clear that they should use the transport_*() functions instead, and also allowing the interface between the transport mechanism and an individual transport to independently evolve. This is superficially a reversal of commit 824d5776c3f2 ("Refactor struct transport_ops inlined into struct transport", 2007-09-19). However, the scope of the involved variables was neither affected nor discussed in that commit, and I think that the advantages in making those functions more private outweigh the advantages described in that commit's commit message. A minor additional point is that the code has gotten more complicated since then, in that the function-pointer variables are potentially mutated twice (once initially and once if transport_take_over() is invoked), increasing the value of corralling them into their own struct. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.h')
-rw-r--r--transport.h54
1 files changed, 2 insertions, 52 deletions
diff --git a/transport.h b/transport.h
index ab4fe7f..731c78b 100644
--- a/transport.h
+++ b/transport.h
@@ -30,6 +30,8 @@ enum transport_family {
};
struct transport {
+ const struct transport_vtable *vtable;
+
struct remote *remote;
const char *url;
void *data;
@@ -59,58 +61,6 @@ struct transport {
*/
const struct string_list *push_options;
- /**
- * Returns 0 if successful, positive if the option is not
- * recognized or is inapplicable, and negative if the option
- * is applicable but the value is invalid.
- **/
- int (*set_option)(struct transport *connection, const char *name,
- const char *value);
-
- /**
- * Returns a list of the remote side's refs. In order to allow
- * the transport to try to share connections, for_push is a
- * hint as to whether the ultimate operation is a push or a fetch.
- *
- * If the transport is able to determine the remote hash for
- * the ref without a huge amount of effort, it should store it
- * in the ref's old_sha1 field; otherwise it should be all 0.
- **/
- struct ref *(*get_refs_list)(struct transport *transport, int for_push);
-
- /**
- * Fetch the objects for the given refs. Note that this gets
- * an array, and should ignore the list structure.
- *
- * If the transport did not get hashes for refs in
- * get_refs_list(), it should set the old_sha1 fields in the
- * provided refs now.
- **/
- int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs);
-
- /**
- * Push the objects and refs. Send the necessary objects, and
- * then, for any refs where peer_ref is set and
- * peer_ref->new_oid is different from old_oid, tell the
- * remote side to update each ref in the list from old_oid to
- * peer_ref->new_oid.
- *
- * Where possible, set the status for each ref appropriately.
- *
- * The transport must modify new_sha1 in the ref to the new
- * value if the remote accepted the change. Note that this
- * could be a different value from peer_ref->new_oid if the
- * process involved generating new commits.
- **/
- int (*push_refs)(struct transport *transport, struct ref *refs, int flags);
- int (*connect)(struct transport *connection, const char *name,
- const char *executable, int fd[2]);
-
- /** get_refs_list(), fetch(), and push_refs() can keep
- * resources (such as a connection) reserved for further
- * use. disconnect() releases these resources.
- **/
- int (*disconnect)(struct transport *connection);
char *pack_lockfile;
signed verbose : 3;
/**