git/builtin/fast-import.c

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "config.h"
#include "lockfile.h"
#include "object.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
#include "delta.h"
#include "pack.h"
#include "path.h"
#include "refs.h"
#include "csum-file.h"
#include "quote.h"
#include "dir.h"
#include "run-command.h"
#include "packfile.h"
#include "object-file.h"
#include "object-name.h"
#include "object-store-ll.h"
#include "mem-pool.h"
#include "commit-reach.h"
#include "khash.h"
#include "date.h"

#define PACK_ID_BITS
#define MAX_PACK_ID
#define DEPTH_BITS
#define MAX_DEPTH

/*
 * We abuse the setuid bit on directories to mean "do not delta".
 */
#define NO_DELTA

/*
 * The amount of additional space required in order to write an object into the
 * current pack. This is the hash lengths at the end of the pack, plus the
 * length of one object ID.
 */
#define PACK_SIZE_THRESHOLD

struct object_entry {};

static int object_entry_hashcmp(const void *map_data UNUSED,
				const struct hashmap_entry *eptr,
				const struct hashmap_entry *entry_or_key,
				const void *keydata)
{}

struct object_entry_pool {};

struct mark_set {};

struct last_object {};

struct atom_str {};

struct tree_content;
struct tree_entry {};

struct tree_content {};

struct avail_tree_content {};

struct branch {};

struct tag {};

struct hash_list {};

whenspec_type;

struct recent_command {};

mark_set_inserter_t;
each_mark_fn_t;

/* Configured limits on output */
static unsigned long max_depth =;
static off_t max_packsize;
static int unpack_limit =;
static int force_update;

/* Stats and misc. counters */
static uintmax_t alloc_count;
static uintmax_t marks_set_count;
static uintmax_t object_count_by_type[1 << TYPE_BITS];
static uintmax_t duplicate_count_by_type[1 << TYPE_BITS];
static uintmax_t delta_count_by_type[1 << TYPE_BITS];
static uintmax_t delta_count_attempts_by_type[1 << TYPE_BITS];
static unsigned long object_count;
static unsigned long branch_count;
static unsigned long branch_load_count;
static int failure;
static FILE *pack_edges;
static unsigned int show_stats =;
static int global_argc;
static const char **global_argv;
static const char *global_prefix;

/* Memory pools */
static struct mem_pool fi_mem_pool =;

/* Atom management */
static unsigned int atom_table_sz =;
static unsigned int atom_cnt;
static struct atom_str **atom_table;

/* The .pack file being generated */
static struct pack_idx_option pack_idx_opts;
static unsigned int pack_id;
static struct hashfile *pack_file;
static struct packed_git *pack_data;
static struct packed_git **all_packs;
static off_t pack_size;

/* Table of objects we've written. */
static unsigned int object_entry_alloc =;
static struct object_entry_pool *blocks;
static struct hashmap object_table;
static struct mark_set *marks;
static char *export_marks_file;
static char *import_marks_file;
static int import_marks_file_from_stream;
static int import_marks_file_ignore_missing;
static int import_marks_file_done;
static int relative_marks_paths;

/* Our last blob */
static struct last_object last_blob =;

/* Tree management */
static unsigned int tree_entry_alloc =;
static void *avail_tree_entry;
static unsigned int avail_tree_table_sz =;
static struct avail_tree_content **avail_tree_table;
static size_t tree_entry_allocd;
static struct strbuf old_tree =;
static struct strbuf new_tree =;

/* Branch data */
static unsigned long max_active_branches =;
static unsigned long cur_active_branches;
static unsigned long branch_table_sz =;
static struct branch **branch_table;
static struct branch *active_branches;

/* Tag data */
static struct tag *first_tag;
static struct tag *last_tag;

/* Input stream parsing */
static whenspec_type whenspec =;
static struct strbuf command_buf =;
static int unread_command_buf;
static struct recent_command cmd_hist =;
static struct recent_command *cmd_tail =;
static struct recent_command *rc_free;
static unsigned int cmd_save =;
static uintmax_t next_mark;
static struct strbuf new_data =;
static int seen_data_command;
static int require_explicit_termination;
static int allow_unsafe_features;

/* Signal handling */
static volatile sig_atomic_t checkpoint_requested;

/* Submodule marks */
static struct string_list sub_marks_from =;
static struct string_list sub_marks_to =;
static kh_oid_map_t *sub_oid_map;

/* Where to write output of cat-blob commands */
static int cat_blob_fd =;

static void parse_argv(void);
static void parse_get_mark(const char *p);
static void parse_cat_blob(const char *p);
static void parse_ls(const char *p, struct branch *b);

static void for_each_mark(struct mark_set *m, uintmax_t base, each_mark_fn_t callback, void *p)
{}

static void dump_marks_fn(uintmax_t mark, void *object, void *cbp) {}

static void write_branch_report(FILE *rpt, struct branch *b)
{}

static void write_crash_report(const char *err)
{}

static void end_packfile(void);
static void unkeep_all_packs(void);
static void dump_marks(void);

static NORETURN void die_nicely(const char *err, va_list params)
{}

#ifndef SIGUSR1	/* Windows, for example */

static void set_checkpoint_signal(void)
{
}

#else

static void checkpoint_signal(int signo UNUSED)
{}

static void set_checkpoint_signal(void)
{}

#endif

static void alloc_objects(unsigned int cnt)
{}

static struct object_entry *new_object(struct object_id *oid)
{}

static struct object_entry *find_object(struct object_id *oid)
{}

static struct object_entry *insert_object(struct object_id *oid)
{}

static void invalidate_pack_id(unsigned int id)
{}

static unsigned int hc_str(const char *s, size_t len)
{}

static void insert_mark(struct mark_set **top, uintmax_t idnum, struct object_entry *oe)
{}

static void *find_mark(struct mark_set *s, uintmax_t idnum)
{}

static struct atom_str *to_atom(const char *s, unsigned short len)
{}

static struct branch *lookup_branch(const char *name)
{}

static struct branch *new_branch(const char *name)
{}

static unsigned int hc_entries(unsigned int cnt)
{}

static struct tree_content *new_tree_content(unsigned int cnt)
{}

static void release_tree_entry(struct tree_entry *e);
static void release_tree_content(struct tree_content *t)
{}

static void release_tree_content_recursive(struct tree_content *t)
{}

static struct tree_content *grow_tree_content(
	struct tree_content *t,
	int amt)
{}

static struct tree_entry *new_tree_entry(void)
{}

static void release_tree_entry(struct tree_entry *e)
{}

static struct tree_content *dup_tree_content(struct tree_content *s)
{}

static void start_packfile(void)
{}

static const char *create_index(void)
{}

static char *keep_pack(const char *curr_index_name)
{}

static void unkeep_all_packs(void)
{}

static int loosen_small_pack(const struct packed_git *p)
{}

static void end_packfile(void)
{}

static void cycle_packfile(void)
{}

static int store_object(
	enum object_type type,
	struct strbuf *dat,
	struct last_object *last,
	struct object_id *oidout,
	uintmax_t mark)
{}

static void truncate_pack(struct hashfile_checkpoint *checkpoint)
{}

static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
{}

/* All calls must be guarded by find_object() or find_mark() to
 * ensure the 'struct object_entry' passed was written by this
 * process instance.  We unpack the entry by the offset, avoiding
 * the need for the corresponding .idx file.  This unpacking rule
 * works because we only use OBJ_REF_DELTA within the packfiles
 * created by fast-import.
 *
 * oe must not be NULL.  Such an oe usually comes from giving
 * an unknown SHA-1 to find_object() or an undefined mark to
 * find_mark().  Callers must test for this condition and use
 * the standard read_sha1_file() when it happens.
 *
 * oe->pack_id must not be MAX_PACK_ID.  Such an oe is usually from
 * find_mark(), where the mark was reloaded from an existing marks
 * file and is referencing an object that this fast-import process
 * instance did not write out to a packfile.  Callers must test for
 * this condition and use read_sha1_file() instead.
 */
static void *gfi_unpack_entry(
	struct object_entry *oe,
	unsigned long *sizep)
{}

static void load_tree(struct tree_entry *root)
{}

static int tecmp0 (const void *_a, const void *_b)
{}

static int tecmp1 (const void *_a, const void *_b)
{}

static void mktree(struct tree_content *t, int v, struct strbuf *b)
{}

static void store_tree(struct tree_entry *root)
{}

static void tree_content_replace(
	struct tree_entry *root,
	const struct object_id *oid,
	const uint16_t mode,
	struct tree_content *newtree)
{}

static int tree_content_set(
	struct tree_entry *root,
	const char *p,
	const struct object_id *oid,
	const uint16_t mode,
	struct tree_content *subtree)
{}

static int tree_content_remove(
	struct tree_entry *root,
	const char *p,
	struct tree_entry *backup_leaf,
	int allow_root)
{}

static int tree_content_get(
	struct tree_entry *root,
	const char *p,
	struct tree_entry *leaf,
	int allow_root)
{}

static int update_branch(struct branch *b)
{}

static void dump_branches(void)
{}

static void dump_tags(void)
{}

static void dump_marks(void)
{}

static void insert_object_entry(struct mark_set **s, struct object_id *oid, uintmax_t mark)
{}

static void insert_oid_entry(struct mark_set **s, struct object_id *oid, uintmax_t mark)
{}

static void read_mark_file(struct mark_set **s, FILE *f, mark_set_inserter_t inserter)
{}

static void read_marks(void)
{}


static int read_next_command(void)
{}

static void skip_optional_lf(void)
{}

static void parse_mark(void)
{}

static void parse_original_identifier(void)
{}

static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)
{}

static int validate_raw_date(const char *src, struct strbuf *result, int strict)
{}

static char *parse_ident(const char *buf)
{}

static void parse_and_store_blob(
	struct last_object *last,
	struct object_id *oidout,
	uintmax_t mark)
{}

static void parse_new_blob(void)
{}

static void unload_one_branch(void)
{}

static void load_branch(struct branch *b)
{}

static unsigned char convert_num_notes_to_fanout(uintmax_t num_notes)
{}

static void construct_path_with_fanout(const char *hex_sha1,
		unsigned char fanout, char *path)
{}

static uintmax_t do_change_note_fanout(
		struct tree_entry *orig_root, struct tree_entry *root,
		char *hex_oid, unsigned int hex_oid_len,
		char *fullpath, unsigned int fullpath_len,
		unsigned char fanout)
{}

static uintmax_t change_note_fanout(struct tree_entry *root,
		unsigned char fanout)
{}

static int parse_mapped_oid_hex(const char *hex, struct object_id *oid, const char **end)
{}

/*
 * Given a pointer into a string, parse a mark reference:
 *
 *   idnum ::= ':' bigint;
 *
 * Update *endptr to point to the first character after the value.
 *
 * Complain if the following character is not what is expected,
 * either a space or end of the string.
 */
static uintmax_t parse_mark_ref(const char *p, char **endptr)
{}

/*
 * Parse the mark reference, and complain if this is not the end of
 * the string.
 */
static uintmax_t parse_mark_ref_eol(const char *p)
{}

/*
 * Parse the mark reference, demanding a trailing space. Update *p to
 * point to the first character after the space.
 */
static uintmax_t parse_mark_ref_space(const char **p)
{}

/*
 * Parse the path string into the strbuf. The path can either be quoted with
 * escape sequences or unquoted without escape sequences. Unquoted strings may
 * contain spaces only if `is_last_field` is nonzero; otherwise, it stops
 * parsing at the first space.
 */
static void parse_path(struct strbuf *sb, const char *p, const char **endp,
		int is_last_field, const char *field)
{}

/*
 * Parse the path string into the strbuf, and complain if this is not the end of
 * the string. Unquoted strings may contain spaces.
 */
static void parse_path_eol(struct strbuf *sb, const char *p, const char *field)
{}

/*
 * Parse the path string into the strbuf, and ensure it is followed by a space.
 * Unquoted strings may not contain spaces. Update *endp to point to the first
 * character after the space.
 */
static void parse_path_space(struct strbuf *sb, const char *p,
		const char **endp, const char *field)
{}

static void file_change_m(const char *p, struct branch *b)
{}

static void file_change_d(const char *p, struct branch *b)
{}

static void file_change_cr(const char *p, struct branch *b, int rename)
{}

static void note_change_n(const char *p, struct branch *b, unsigned char *old_fanout)
{}

static void file_change_deleteall(struct branch *b)
{}

static void parse_from_commit(struct branch *b, char *buf, unsigned long size)
{}

static void parse_from_existing(struct branch *b)
{}

static int parse_objectish(struct branch *b, const char *objectish)
{}

static int parse_from(struct branch *b)
{}

static int parse_objectish_with_prefix(struct branch *b, const char *prefix)
{}

static struct hash_list *parse_merge(unsigned int *count)
{}

static void parse_new_commit(const char *arg)
{}

static void parse_new_tag(const char *arg)
{}

static void parse_reset_branch(const char *arg)
{}

static void cat_blob_write(const char *buf, unsigned long size)
{}

static void cat_blob(struct object_entry *oe, struct object_id *oid)
{}

static void parse_get_mark(const char *p)
{}

static void parse_cat_blob(const char *p)
{}

static struct object_entry *dereference(struct object_entry *oe,
					struct object_id *oid)
{}

static void insert_mapped_mark(uintmax_t mark, void *object, void *cbp)
{}

static void build_mark_map_one(struct mark_set *from, struct mark_set *to)
{}

static void build_mark_map(struct string_list *from, struct string_list *to)
{}

static struct object_entry *parse_treeish_dataref(const char **p)
{}

static void print_ls(int mode, const unsigned char *hash, const char *path)
{}

static void parse_ls(const char *p, struct branch *b)
{}

static void checkpoint(void)
{}

static void parse_checkpoint(void)
{}

static void parse_progress(void)
{}

static void parse_alias(void)
{}

static char* make_fast_import_path(const char *path)
{}

static void option_import_marks(const char *marks,
					int from_stream, int ignore_missing)
{}

static void option_date_format(const char *fmt)
{}

static unsigned long ulong_arg(const char *option, const char *arg)
{}

static void option_depth(const char *depth)
{}

static void option_active_branches(const char *branches)
{}

static void option_export_marks(const char *marks)
{}

static void option_cat_blob_fd(const char *fd)
{}

static void option_export_pack_edges(const char *edges)
{}

static void option_rewrite_submodules(const char *arg, struct string_list *list)
{}

static int parse_one_option(const char *option)
{}

static void check_unsafe_feature(const char *feature, int from_stream)
{}

static int parse_one_feature(const char *feature, int from_stream)
{}

static void parse_feature(const char *feature)
{}

static void parse_option(const char *option)
{}

static void git_pack_config(void)
{}

static const char fast_import_usage[] =;

static void parse_argv(void)
{}

int cmd_fast_import(int argc,
		    const char **argv,
		    const char *prefix,
		    struct repository *repo UNUSED)
{}