Imported Upstream version 2.13.3
[platform/upstream/git.git] / transport.h
index 1631a35..bc55715 100644 (file)
@@ -2,15 +2,31 @@
 #define TRANSPORT_H
 
 #include "cache.h"
+#include "run-command.h"
 #include "remote.h"
 
+struct string_list;
+
 struct git_transport_options {
        unsigned thin : 1;
        unsigned keep : 1;
        unsigned followtags : 1;
+       unsigned check_self_contained_and_connected : 1;
+       unsigned self_contained_and_connected : 1;
+       unsigned update_shallow : 1;
+       unsigned deepen_relative : 1;
        int depth;
+       const char *deepen_since;
+       const struct string_list *deepen_not;
        const char *uploadpack;
        const char *receivepack;
+       struct push_cas_option *cas;
+};
+
+enum transport_family {
+       TRANSPORT_FAMILY_ALL = 0,
+       TRANSPORT_FAMILY_IPV4,
+       TRANSPORT_FAMILY_IPV6
 };
 
 struct transport {
@@ -25,6 +41,24 @@ struct transport {
         */
        unsigned got_remote_refs : 1;
 
+       /*
+        * Transports that call take-over destroys the data specific to
+        * the transport type while doing so, and cannot be reused.
+        */
+       unsigned cannot_reuse : 1;
+
+       /*
+        * A hint from caller that it will be performing a clone, not
+        * normal fetch. IOW the repository is guaranteed empty.
+        */
+       unsigned cloning : 1;
+
+       /*
+        * These strings will be passed to the {pre, post}-receive hook,
+        * on the remote side, if both sides support the push options capability.
+        */
+       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
@@ -57,15 +91,15 @@ struct transport {
        /**
         * Push the objects and refs. Send the necessary objects, and
         * then, for any refs where peer_ref is set and
-        * peer_ref->new_sha1 is different from old_sha1, tell the
-        * remote side to update each ref in the list from old_sha1 to
-        * peer_ref->new_sha1.
+        * 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_sha1 if the
+        * 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);
@@ -74,7 +108,7 @@ struct transport {
                       const char *executable, int fd[2]);
 
        /** get_refs_list(), fetch(), and push_refs() can keep
-        * resources (such as a connection) reserved for futher
+        * resources (such as a connection) reserved for further
         * use. disconnect() releases these resources.
         **/
        int (*disconnect)(struct transport *connection);
@@ -93,22 +127,51 @@ struct transport {
         * actually turns out to be smart.
         */
        struct git_transport_options *smart_options;
+
+       enum transport_family family;
 };
 
-#define TRANSPORT_PUSH_ALL 1
-#define TRANSPORT_PUSH_FORCE 2
-#define TRANSPORT_PUSH_DRY_RUN 4
-#define TRANSPORT_PUSH_MIRROR 8
-#define TRANSPORT_PUSH_PORCELAIN 16
-#define TRANSPORT_PUSH_SET_UPSTREAM 32
-#define TRANSPORT_RECURSE_SUBMODULES_CHECK 64
-#define TRANSPORT_PUSH_PRUNE 128
+#define TRANSPORT_PUSH_ALL                     (1<<0)
+#define TRANSPORT_PUSH_FORCE                   (1<<1)
+#define TRANSPORT_PUSH_DRY_RUN                 (1<<2)
+#define TRANSPORT_PUSH_MIRROR                  (1<<3)
+#define TRANSPORT_PUSH_PORCELAIN               (1<<4)
+#define TRANSPORT_PUSH_SET_UPSTREAM            (1<<5)
+#define TRANSPORT_RECURSE_SUBMODULES_CHECK     (1<<6)
+#define TRANSPORT_PUSH_PRUNE                   (1<<7)
+#define TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND (1<<8)
+#define TRANSPORT_PUSH_NO_HOOK                 (1<<9)
+#define TRANSPORT_PUSH_FOLLOW_TAGS             (1<<10)
+#define TRANSPORT_PUSH_CERT_ALWAYS             (1<<11)
+#define TRANSPORT_PUSH_CERT_IF_ASKED           (1<<12)
+#define TRANSPORT_PUSH_ATOMIC                  (1<<13)
+#define TRANSPORT_PUSH_OPTIONS                 (1<<14)
+#define TRANSPORT_RECURSE_SUBMODULES_ONLY      (1<<15)
 
-#define TRANSPORT_SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
+extern int transport_summary_width(const struct ref *refs);
 
 /* Returns a transport suitable for the url */
 struct transport *transport_get(struct remote *, const char *);
 
+/*
+ * Check whether a transport is allowed by the environment.
+ *
+ * Type should generally be the URL scheme, as described in
+ * Documentation/git.txt
+ *
+ * from_user specifies if the transport was given by the user.  If unknown pass
+ * a -1 to read from the environment to determine if the transport was given by
+ * the user.
+ *
+ */
+int is_transport_allowed(const char *type, int from_user);
+
+/*
+ * Check whether a transport is allowed by the environment,
+ * and die otherwise.
+ */
+void transport_check_allowed(const char *type);
+
 /* Transport options which apply to git:// and scp-style URLs */
 
 /* The program to use on the remote side to send a pack */
@@ -120,15 +183,33 @@ struct transport *transport_get(struct remote *, const char *);
 /* Transfer the data as a thin pack if not null */
 #define TRANS_OPT_THIN "thin"
 
+/* Check the current value of the remote ref */
+#define TRANS_OPT_CAS "cas"
+
 /* Keep the pack that was transferred if not null */
 #define TRANS_OPT_KEEP "keep"
 
 /* Limit the depth of the fetch if not null */
 #define TRANS_OPT_DEPTH "depth"
 
+/* Limit the depth of the fetch based on time if not null */
+#define TRANS_OPT_DEEPEN_SINCE "deepen-since"
+
+/* Limit the depth of the fetch based on revs if not null */
+#define TRANS_OPT_DEEPEN_NOT "deepen-not"
+
+/* Limit the deepen of the fetch if not null */
+#define TRANS_OPT_DEEPEN_RELATIVE "deepen-relative"
+
 /* Aggressively fetch annotated tags if possible */
 #define TRANS_OPT_FOLLOWTAGS "followtags"
 
+/* Accept refs that may update .git/shallow without --depth */
+#define TRANS_OPT_UPDATE_SHALLOW "updateshallow"
+
+/* Send push certificates */
+#define TRANS_OPT_PUSH_CERT "pushcert"
+
 /**
  * Returns 0 if the option was used, non-zero otherwise. Prints a
  * message to stderr if the option is not used.
@@ -138,11 +219,15 @@ int transport_set_option(struct transport *transport, const char *name,
 void transport_set_verbosity(struct transport *transport, int verbosity,
        int force_progress);
 
-#define NON_FF_HEAD 1
-#define NON_FF_OTHER 2
+#define REJECT_NON_FF_HEAD     0x01
+#define REJECT_NON_FF_OTHER    0x02
+#define REJECT_ALREADY_EXISTS  0x04
+#define REJECT_FETCH_FIRST     0x08
+#define REJECT_NEEDS_FORCE     0x10
+
 int transport_push(struct transport *connection,
                   int refspec_nr, const char **refspec, int flags,
-                  int * nonfastforward);
+                  unsigned int * reject_reasons);
 
 const struct ref *transport_get_remote_refs(struct transport *transport);
 
@@ -160,7 +245,7 @@ int transport_connect(struct transport *transport, const char *name,
 int transport_helper_init(struct transport *transport, const char *name);
 int bidirectional_transfer_loop(int input, int output);
 
-/* common methods used by transport.c and builtin-send-pack.c */
+/* common methods used by transport.c and builtin/send-pack.c */
 void transport_verify_remote_names(int nr_heads, const char **heads);
 
 void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int verbose);
@@ -168,9 +253,8 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v
 int transport_refs_pushed(struct ref *ref);
 
 void transport_print_push_status(const char *dest, struct ref *refs,
-                 int verbose, int porcelain, int *nonfastforward);
+                 int verbose, int porcelain, unsigned int *reject_reasons);
 
-typedef void alternate_ref_fn(const struct ref *, void *);
+typedef void alternate_ref_fn(const char *refname, const struct object_id *oid, void *);
 extern void for_each_alternate_ref(alternate_ref_fn, void *);
-
 #endif