THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
8.0KB

  1. #ifndef TRANSPORT_H
  2. #define TRANSPORT_H
  3. #include "cache.h"
  4. #include "run-command.h"
  5. #include "remote.h"
  6. #include "list-objects-filter-options.h"
  7. struct string_list;
  8. struct git_transport_options {
  9. unsigned thin : 1;
  10. unsigned keep : 1;
  11. unsigned followtags : 1;
  12. unsigned check_self_contained_and_connected : 1;
  13. unsigned self_contained_and_connected : 1;
  14. unsigned update_shallow : 1;
  15. unsigned deepen_relative : 1;
  16. unsigned from_promisor : 1;
  17. unsigned no_dependents : 1;
  18. /*
  19. * If this transport supports connect or stateless-connect,
  20. * the corresponding field in struct fetch_pack_args is copied
  21. * here after fetching.
  22. *
  23. * See the definition of connectivity_checked in struct
  24. * fetch_pack_args for more information.
  25. */
  26. unsigned connectivity_checked:1;
  27. int depth;
  28. const char *deepen_since;
  29. const struct string_list *deepen_not;
  30. const char *uploadpack;
  31. const char *receivepack;
  32. struct push_cas_option *cas;
  33. struct list_objects_filter_options filter_options;
  34. /*
  35. * This is only used during fetch. See the documentation of
  36. * negotiation_tips in struct fetch_pack_args.
  37. *
  38. * This field is only supported by transports that support connect or
  39. * stateless_connect. Set this field directly instead of using
  40. * transport_set_option().
  41. */
  42. struct oid_array *negotiation_tips;
  43. };
  44. enum transport_family {
  45. TRANSPORT_FAMILY_ALL = 0,
  46. TRANSPORT_FAMILY_IPV4,
  47. TRANSPORT_FAMILY_IPV6
  48. };
  49. struct transport {
  50. const struct transport_vtable *vtable;
  51. struct remote *remote;
  52. const char *url;
  53. void *data;
  54. const struct ref *remote_refs;
  55. /**
  56. * Indicates whether we already called get_refs_list(); set by
  57. * transport.c::transport_get_remote_refs().
  58. */
  59. unsigned got_remote_refs : 1;
  60. /*
  61. * Transports that call take-over destroys the data specific to
  62. * the transport type while doing so, and cannot be reused.
  63. */
  64. unsigned cannot_reuse : 1;
  65. /*
  66. * A hint from caller that it will be performing a clone, not
  67. * normal fetch. IOW the repository is guaranteed empty.
  68. */
  69. unsigned cloning : 1;
  70. /*
  71. * Indicates that the transport is connected via a half-duplex
  72. * connection and should operate in stateless-rpc mode.
  73. */
  74. unsigned stateless_rpc : 1;
  75. /*
  76. * These strings will be passed to the {pre, post}-receive hook,
  77. * on the remote side, if both sides support the push options capability.
  78. */
  79. const struct string_list *push_options;
  80. /*
  81. * These strings will be passed to the remote side on each command
  82. * request, if both sides support the server-option capability.
  83. */
  84. const struct string_list *server_options;
  85. char *pack_lockfile;
  86. signed verbose : 3;
  87. /**
  88. * Transports should not set this directly, and should use this
  89. * value without having to check isatty(2), -q/--quiet
  90. * (transport->verbose < 0), etc. - checking has already been done
  91. * in transport_set_verbosity().
  92. **/
  93. unsigned progress : 1;
  94. /*
  95. * If transport is at least potentially smart, this points to
  96. * git_transport_options structure to use in case transport
  97. * actually turns out to be smart.
  98. */
  99. struct git_transport_options *smart_options;
  100. enum transport_family family;
  101. };
  102. #define TRANSPORT_PUSH_ALL (1<<0)
  103. #define TRANSPORT_PUSH_FORCE (1<<1)
  104. #define TRANSPORT_PUSH_DRY_RUN (1<<2)
  105. #define TRANSPORT_PUSH_MIRROR (1<<3)
  106. #define TRANSPORT_PUSH_PORCELAIN (1<<4)
  107. #define TRANSPORT_PUSH_SET_UPSTREAM (1<<5)
  108. #define TRANSPORT_RECURSE_SUBMODULES_CHECK (1<<6)
  109. #define TRANSPORT_PUSH_PRUNE (1<<7)
  110. #define TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND (1<<8)
  111. #define TRANSPORT_PUSH_NO_HOOK (1<<9)
  112. #define TRANSPORT_PUSH_FOLLOW_TAGS (1<<10)
  113. #define TRANSPORT_PUSH_CERT_ALWAYS (1<<11)
  114. #define TRANSPORT_PUSH_CERT_IF_ASKED (1<<12)
  115. #define TRANSPORT_PUSH_ATOMIC (1<<13)
  116. #define TRANSPORT_PUSH_OPTIONS (1<<14)
  117. #define TRANSPORT_RECURSE_SUBMODULES_ONLY (1<<15)
  118. int transport_summary_width(const struct ref *refs);
  119. /* Returns a transport suitable for the url */
  120. struct transport *transport_get(struct remote *, const char *);
  121. /*
  122. * Check whether a transport is allowed by the environment.
  123. *
  124. * Type should generally be the URL scheme, as described in
  125. * Documentation/git.txt
  126. *
  127. * from_user specifies if the transport was given by the user. If unknown pass
  128. * a -1 to read from the environment to determine if the transport was given by
  129. * the user.
  130. *
  131. */
  132. int is_transport_allowed(const char *type, int from_user);
  133. /*
  134. * Check whether a transport is allowed by the environment,
  135. * and die otherwise.
  136. */
  137. void transport_check_allowed(const char *type);
  138. /* Transport options which apply to git:// and scp-style URLs */
  139. /* The program to use on the remote side to send a pack */
  140. #define TRANS_OPT_UPLOADPACK "uploadpack"
  141. /* The program to use on the remote side to receive a pack */
  142. #define TRANS_OPT_RECEIVEPACK "receivepack"
  143. /* Transfer the data as a thin pack if not null */
  144. #define TRANS_OPT_THIN "thin"
  145. /* Check the current value of the remote ref */
  146. #define TRANS_OPT_CAS "cas"
  147. /* Keep the pack that was transferred if not null */
  148. #define TRANS_OPT_KEEP "keep"
  149. /* Limit the depth of the fetch if not null */
  150. #define TRANS_OPT_DEPTH "depth"
  151. /* Limit the depth of the fetch based on time if not null */
  152. #define TRANS_OPT_DEEPEN_SINCE "deepen-since"
  153. /* Limit the depth of the fetch based on revs if not null */
  154. #define TRANS_OPT_DEEPEN_NOT "deepen-not"
  155. /* Limit the deepen of the fetch if not null */
  156. #define TRANS_OPT_DEEPEN_RELATIVE "deepen-relative"
  157. /* Aggressively fetch annotated tags if possible */
  158. #define TRANS_OPT_FOLLOWTAGS "followtags"
  159. /* Accept refs that may update .git/shallow without --depth */
  160. #define TRANS_OPT_UPDATE_SHALLOW "updateshallow"
  161. /* Send push certificates */
  162. #define TRANS_OPT_PUSH_CERT "pushcert"
  163. /* Indicate that these objects are being fetched by a promisor */
  164. #define TRANS_OPT_FROM_PROMISOR "from-promisor"
  165. /*
  166. * Indicate that only the objects wanted need to be fetched, not their
  167. * dependents
  168. */
  169. #define TRANS_OPT_NO_DEPENDENTS "no-dependents"
  170. /* Filter objects for partial clone and fetch */
  171. #define TRANS_OPT_LIST_OBJECTS_FILTER "filter"
  172. /* Request atomic (all-or-nothing) updates when pushing */
  173. #define TRANS_OPT_ATOMIC "atomic"
  174. /**
  175. * Returns 0 if the option was used, non-zero otherwise. Prints a
  176. * message to stderr if the option is not used.
  177. **/
  178. int transport_set_option(struct transport *transport, const char *name,
  179. const char *value);
  180. void transport_set_verbosity(struct transport *transport, int verbosity,
  181. int force_progress);
  182. #define REJECT_NON_FF_HEAD 0x01
  183. #define REJECT_NON_FF_OTHER 0x02
  184. #define REJECT_ALREADY_EXISTS 0x04
  185. #define REJECT_FETCH_FIRST 0x08
  186. #define REJECT_NEEDS_FORCE 0x10
  187. int transport_push(struct repository *repo,
  188. struct transport *connection,
  189. struct refspec *rs, int flags,
  190. unsigned int * reject_reasons);
  191. /*
  192. * Retrieve refs from a remote.
  193. *
  194. * Optionally a list of ref prefixes can be provided which can be sent to the
  195. * server (when communicating using protocol v2) to enable it to limit the ref
  196. * advertisement. Since ref filtering is done on the server's end (and only
  197. * when using protocol v2), this can return refs which don't match the provided
  198. * ref_prefixes.
  199. */
  200. const struct ref *transport_get_remote_refs(struct transport *transport,
  201. const struct argv_array *ref_prefixes);
  202. int transport_fetch_refs(struct transport *transport, struct ref *refs);
  203. void transport_unlock_pack(struct transport *transport);
  204. int transport_disconnect(struct transport *transport);
  205. char *transport_anonymize_url(const char *url);
  206. void transport_take_over(struct transport *transport,
  207. struct child_process *child);
  208. int transport_connect(struct transport *transport, const char *name,
  209. const char *exec, int fd[2]);
  210. /* Transport methods defined outside transport.c */
  211. int transport_helper_init(struct transport *transport, const char *name);
  212. int bidirectional_transfer_loop(int input, int output);
  213. /* common methods used by transport.c and builtin/send-pack.c */
  214. void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int verbose);
  215. int transport_refs_pushed(struct ref *ref);
  216. void transport_print_push_status(const char *dest, struct ref *refs,
  217. int verbose, int porcelain, unsigned int *reject_reasons);
  218. #endif