/* Mostly copied from fast-import.c's main() */ static void init() { int i; reset_pack_idx_option(&pack_idx_opts); git_pack_config(); if (!pack_compression_seen && core_compression_seen) pack_compression_level = core_compression_level; alloc_objects(object_entry_alloc); strbuf_init(&command_buf, 0); atom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*)); branch_table = xcalloc(branch_table_sz, sizeof(struct branch*)); avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*)); marks = pool_calloc(1, sizeof(struct mark_set)); global_argc = 1; rc_free = pool_alloc(cmd_save * sizeof(*rc_free)); for (i = 0; i < (cmd_save - 1); i++) rc_free[i].next = &rc_free[i + 1]; rc_free[cmd_save - 1].next = NULL; prepare_packed_git(); start_packfile(); set_die_routine(die_nicely); initialized = 1; atexit(cleanup); }
/* Lazily create backing packfile for the state */ static void prepare_to_stream(struct bulk_checkin_state *state, unsigned flags) { if (!(flags & HASH_WRITE_OBJECT) || state->f) return; state->f = create_tmp_packfile(&state->pack_tmp_name); reset_pack_idx_option(&state->pack_idx_opts); /* Pretend we are going to write only one object */ state->offset = write_pack_header(state->f, 1); if (!state->offset) die_errno("unable to write pack header"); }