git/transport.h

#ifndef TRANSPORT_H
#define TRANSPORT_H

#include "run-command.h"
#include "remote.h"
#include "list-objects-filter-options.h"
#include "string-list.h"

struct git_transport_options {};

enum transport_family {};

struct bundle_list;
struct transport {};

#define TRANSPORT_PUSH_ALL
#define TRANSPORT_PUSH_FORCE
#define TRANSPORT_PUSH_DRY_RUN
#define TRANSPORT_PUSH_MIRROR
#define TRANSPORT_PUSH_PORCELAIN
#define TRANSPORT_PUSH_SET_UPSTREAM
#define TRANSPORT_RECURSE_SUBMODULES_CHECK
#define TRANSPORT_PUSH_PRUNE
#define TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND
#define TRANSPORT_PUSH_NO_HOOK
#define TRANSPORT_PUSH_FOLLOW_TAGS
#define TRANSPORT_PUSH_CERT_ALWAYS
#define TRANSPORT_PUSH_CERT_IF_ASKED
#define TRANSPORT_PUSH_ATOMIC
#define TRANSPORT_PUSH_OPTIONS
#define TRANSPORT_RECURSE_SUBMODULES_ONLY
#define TRANSPORT_PUSH_FORCE_IF_INCLUDES
#define TRANSPORT_PUSH_AUTO_UPSTREAM

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 */
#define TRANS_OPT_UPLOADPACK

/* The program to use on the remote side to receive a pack */
#define TRANS_OPT_RECEIVEPACK

/* Transfer the data as a thin pack if not null */
#define TRANS_OPT_THIN

/* Check the current value of the remote ref */
#define TRANS_OPT_CAS

/* Keep the pack that was transferred if not null */
#define TRANS_OPT_KEEP

/* Limit the depth of the fetch if not null */
#define TRANS_OPT_DEPTH

/* Limit the depth of the fetch based on time if not null */
#define TRANS_OPT_DEEPEN_SINCE

/* Limit the depth of the fetch based on revs if not null */
#define TRANS_OPT_DEEPEN_NOT

/* Limit the deepen of the fetch if not null */
#define TRANS_OPT_DEEPEN_RELATIVE

/* Aggressively fetch annotated tags if possible */
#define TRANS_OPT_FOLLOWTAGS

/* Reject shallow repo transport */
#define TRANS_OPT_REJECT_SHALLOW

/* Accept refs that may update .git/shallow without --depth */
#define TRANS_OPT_UPDATE_SHALLOW

/* Send push certificates */
#define TRANS_OPT_PUSH_CERT

/* Indicate that these objects are being fetched by a promisor */
#define TRANS_OPT_FROM_PROMISOR

/* Filter objects for partial clone and fetch */
#define TRANS_OPT_LIST_OBJECTS_FILTER

/* Refetch all objects without negotiating */
#define TRANS_OPT_REFETCH

/* Request atomic (all-or-nothing) updates when pushing */
#define TRANS_OPT_ATOMIC

/* Require remote changes to be integrated locally. */
#define TRANS_OPT_FORCE_IF_INCLUDES

/**
 * Returns 0 if the option was used, non-zero otherwise. Prints a
 * message to stderr if the option is not used.
 **/
int transport_set_option(struct transport *transport, const char *name,
			 const char *value);
void transport_set_verbosity(struct transport *transport, int verbosity,
	int force_progress);

#define REJECT_NON_FF_HEAD
#define REJECT_NON_FF_OTHER
#define REJECT_ALREADY_EXISTS
#define REJECT_FETCH_FIRST
#define REJECT_NEEDS_FORCE
#define REJECT_REF_NEEDS_UPDATE

int transport_push(struct repository *repo,
		   struct transport *connection,
		   struct refspec *rs, int flags,
		   unsigned int * reject_reasons);

struct transport_ls_refs_options {};
#define TRANSPORT_LS_REFS_OPTIONS_INIT

/**
 * Release the "struct transport_ls_refs_options".
 */
void transport_ls_refs_options_release(struct transport_ls_refs_options *opts);

/*
 * Retrieve refs from a remote.
 */
const struct ref *transport_get_remote_refs(struct transport *transport,
					    struct transport_ls_refs_options *transport_options);

/**
 * Retrieve bundle URI(s) from a remote. Populates "struct
 * transport"'s "bundle_uri" and "got_remote_bundle_uri".
 */
int transport_get_remote_bundle_uri(struct transport *transport);

/*
 * Fetch the hash algorithm used by a remote.
 *
 * This can only be called after fetching the remote refs.
 */
const struct git_hash_algo *transport_get_hash_algo(struct transport *transport);
int transport_fetch_refs(struct transport *transport, struct ref *refs);

/*
 * If this flag is set, unlocking will avoid to call non-async-signal-safe
 * functions. This will necessarily leave behind some data structures which
 * cannot be cleaned up.
 */
#define TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER

/*
 * Unlock all packfiles locked by the transport.
 */
void transport_unlock_pack(struct transport *transport, unsigned int flags);

int transport_disconnect(struct transport *transport);
char *transport_anonymize_url(const char *url);
void transport_take_over(struct transport *transport,
			 struct child_process *child);

int transport_connect(struct transport *transport, const char *name,
		      const char *exec, int fd[2]);

/* Transport methods defined outside transport.c */
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 */
void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int verbose);

int transport_refs_pushed(struct ref *ref);

void transport_print_push_status(const char *dest, struct ref *refs,
		  int verbose, int porcelain, unsigned int *reject_reasons);

/* common method used by transport-helper.c and send-pack.c */
void reject_atomic_push(struct ref *refs, int mirror_mode);

/* common method to parse push-option or server-option from config */
int parse_transport_option(const char *var, const char *value,
			   struct string_list *transport_options);

#endif