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