git/fetch-pack.c

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "repository.h"
#include "config.h"
#include "date.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "lockfile.h"
#include "refs.h"
#include "pkt-line.h"
#include "commit.h"
#include "tag.h"
#include "pack.h"
#include "sideband.h"
#include "fetch-pack.h"
#include "remote.h"
#include "run-command.h"
#include "connect.h"
#include "trace2.h"
#include "version.h"
#include "oid-array.h"
#include "oidset.h"
#include "packfile.h"
#include "object-store-ll.h"
#include "path.h"
#include "connected.h"
#include "fetch-negotiator.h"
#include "fsck.h"
#include "shallow.h"
#include "commit-reach.h"
#include "commit-graph.h"
#include "sigchain.h"
#include "mergesort.h"

static int transfer_unpack_limit =;
static int fetch_unpack_limit =;
static int unpack_limit =;
static int prefer_ofs_delta =;
static int no_done;
static int deepen_since_ok;
static int deepen_not_ok;
static int fetch_fsck_objects =;
static int transfer_fsck_objects =;
static int agent_supported;
static int server_supports_filtering;
static int advertise_sid;
static struct shallow_lock shallow_lock;
static const char *alternate_shallow_file;
static struct fsck_options fsck_options =;
static struct strbuf fsck_msg_types =;
static struct string_list uri_protocols =;

/* Remember to update object flag allocation in object.h */
#define COMPLETE
#define ALTERNATE
#define COMMON
#define REACH_SCRATCH

/*
 * After sending this many "have"s if we do not get any new ACK , we
 * give up traversing our history.
 */
#define MAX_IN_VAIN

static int multi_ack, use_sideband;
/* Allow specifying sha1 if it is a ref tip. */
#define ALLOW_TIP_SHA1
/* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
#define ALLOW_REACHABLE_SHA1
static unsigned int allow_unadvertised_object_request;

__attribute__((format (printf, 2, 3)))
static inline void print_verbose(const struct fetch_pack_args *args,
				 const char *fmt, ...)
{}

struct alternate_object_cache {};

static void cache_one_alternate(const struct object_id *oid,
				void *vcache)
{}

static void for_each_cached_alternate(struct fetch_negotiator *negotiator,
				      void (*cb)(struct fetch_negotiator *,
						 struct object *))
{}

static void die_in_commit_graph_only(const struct object_id *oid)
{}

static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
					       int mark_tags_complete_and_check_obj_db)
{}

static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
			       const struct object_id *oid)
{}

static int rev_list_insert_ref_oid(const char *refname UNUSED,
				   const char *referent UNUSED,
				   const struct object_id *oid,
				   int flag UNUSED,
				   void *cb_data)
{}

enum ack_type {};

static void consume_shallow_list(struct fetch_pack_args *args,
				 struct packet_reader *reader)
{}

static enum ack_type get_ack(struct packet_reader *reader,
			     struct object_id *result_oid)
{}

static void send_request(struct fetch_pack_args *args,
			 int fd, struct strbuf *buf)
{}

static void insert_one_alternate_object(struct fetch_negotiator *negotiator,
					struct object *obj)
{}

#define INITIAL_FLUSH
#define PIPESAFE_FLUSH
#define LARGE_FLUSH

static int next_flush(int stateless_rpc, int count)
{}

static void mark_tips(struct fetch_negotiator *negotiator,
		      const struct oid_array *negotiation_tips)
{}

static void send_filter(struct fetch_pack_args *args,
			struct strbuf *req_buf,
			int server_supports_filter)
{}

static int find_common(struct fetch_negotiator *negotiator,
		       struct fetch_pack_args *args,
		       int fd[2], struct object_id *result_oid,
		       struct ref *refs)
{}

static struct commit_list *complete;

static int mark_complete(const struct object_id *oid)
{}

static int mark_complete_oid(const char *refname UNUSED,
			     const char *referent UNUSED,
			     const struct object_id *oid,
			     int flag UNUSED,
			     void *cb_data UNUSED)
{}

static void mark_recent_complete_commits(struct fetch_pack_args *args,
					 timestamp_t cutoff)
{}

static void add_refs_to_oidset(struct oidset *oids, struct ref *refs)
{}

static int is_unmatched_ref(const struct ref *ref)
{}

static void filter_refs(struct fetch_pack_args *args,
			struct ref **refs,
			struct ref **sought, int nr_sought)
{}

static void mark_alternate_complete(struct fetch_negotiator *negotiator UNUSED,
				    struct object *obj)
{}

/*
 * Mark recent commits available locally and reachable from a local ref as
 * COMPLETE.
 *
 * The cutoff time for recency is determined by this heuristic: it is the
 * earliest commit time of the objects in refs that are commits and that we know
 * the commit time of.
 */
static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
					 struct fetch_pack_args *args,
					 struct ref **refs)
{}

/*
 * Returns 1 if every object pointed to by the given remote refs is available
 * locally and reachable from a local ref, and 0 otherwise.
 */
static int everything_local(struct fetch_pack_args *args,
			    struct ref **refs)
{}

static int sideband_demux(int in UNUSED, int out, void *data)
{}

static void create_promisor_file(const char *keep_name,
				 struct ref **sought, int nr_sought)
{}

static void parse_gitmodules_oids(int fd, struct oidset *gitmodules_oids)
{}

static void add_index_pack_keep_option(struct strvec *args)
{}

/*
 * If packfile URIs were provided, pass a non-NULL pointer to index_pack_args.
 * The strings to pass as the --index-pack-arg arguments to http-fetch will be
 * stored there. (It must be freed by the caller.)
 */
static int get_pack(struct fetch_pack_args *args,
		    int xd[2], struct string_list *pack_lockfiles,
		    struct strvec *index_pack_args,
		    struct ref **sought, int nr_sought,
		    struct oidset *gitmodules_oids)
{}

static int ref_compare_name(const struct ref *a, const struct ref *b)
{}

DEFINE_LIST_SORT();

static int cmp_ref_by_name(const void *a_, const void *b_)
{}

static struct ref *do_fetch_pack(struct fetch_pack_args *args,
				 int fd[2],
				 const struct ref *orig_ref,
				 struct ref **sought, int nr_sought,
				 struct shallow_info *si,
				 struct string_list *pack_lockfiles)
{}

static void add_shallow_requests(struct strbuf *req_buf,
				 const struct fetch_pack_args *args)
{}

static void add_wants(const struct ref *wants, struct strbuf *req_buf)
{}

static void add_common(struct strbuf *req_buf, struct oidset *common)
{}

static int add_haves(struct fetch_negotiator *negotiator,
		     struct strbuf *req_buf,
		     int *haves_to_send)
{}

static void write_fetch_command_and_capabilities(struct strbuf *req_buf,
						 const struct string_list *server_options)
{}

static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
			      struct fetch_pack_args *args,
			      const struct ref *wants, struct oidset *common,
			      int *haves_to_send, int *in_vain,
			      int sideband_all, int seen_ack)
{}

/*
 * Processes a section header in a server's response and checks if it matches
 * `section`.  If the value of `peek` is 1, the header line will be peeked (and
 * not consumed); if 0, the line will be consumed and the function will die if
 * the section header doesn't match what was expected.
 */
static int process_section_header(struct packet_reader *reader,
				  const char *section, int peek)
{}

static int process_ack(struct fetch_negotiator *negotiator,
		       struct packet_reader *reader,
		       struct object_id *common_oid,
		       int *received_ready)
{}

static void receive_shallow_info(struct fetch_pack_args *args,
				 struct packet_reader *reader,
				 struct oid_array *shallows,
				 struct shallow_info *si)
{}

static int cmp_name_ref(const void *name, const void *ref)
{}

static void receive_wanted_refs(struct packet_reader *reader,
				struct ref **sought, int nr_sought)
{}

static void receive_packfile_uris(struct packet_reader *reader,
				  struct string_list *uris)
{}

enum fetch_state {};

static void do_check_stateless_delimiter(int stateless_rpc,
					 struct packet_reader *reader)
{}

static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
				    int fd[2],
				    const struct ref *orig_ref,
				    struct ref **sought, int nr_sought,
				    struct oid_array *shallows,
				    struct shallow_info *si,
				    struct string_list *pack_lockfiles)
{}

static int fetch_pack_config_cb(const char *var, const char *value,
				const struct config_context *ctx, void *cb)
{}

static void fetch_pack_config(void)
{}

static void fetch_pack_setup(void)
{}

static int remove_duplicates_in_refs(struct ref **ref, int nr)
{}

static void update_shallow(struct fetch_pack_args *args,
			   struct ref **sought, int nr_sought,
			   struct shallow_info *si)
{}

static const struct object_id *iterate_ref_map(void *cb_data)
{}

int fetch_pack_fsck_objects(void)
{}

struct ref *fetch_pack(struct fetch_pack_args *args,
		       int fd[],
		       const struct ref *ref,
		       struct ref **sought, int nr_sought,
		       struct oid_array *shallow,
		       struct string_list *pack_lockfiles,
		       enum protocol_version version)
{}

static int add_to_object_array(const struct object_id *oid, void *data)
{}

static void clear_common_flag(struct oidset *s)
{}

void negotiate_using_fetch(const struct oid_array *negotiation_tips,
			   const struct string_list *server_options,
			   int stateless_rpc,
			   int fd[],
			   struct oidset *acked_commits)
{}

int report_unmatched_refs(struct ref **sought, int nr_sought)
{}