git/packfile.c

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "list.h"
#include "pack.h"
#include "repository.h"
#include "dir.h"
#include "mergesort.h"
#include "packfile.h"
#include "delta.h"
#include "hash-lookup.h"
#include "commit.h"
#include "object.h"
#include "tag.h"
#include "trace.h"
#include "tree-walk.h"
#include "tree.h"
#include "object-file.h"
#include "object-store-ll.h"
#include "midx.h"
#include "commit-graph.h"
#include "pack-revindex.h"
#include "promisor-remote.h"

char *odb_pack_name(struct strbuf *buf,
		    const unsigned char *hash,
		    const char *ext)
{}

static unsigned int pack_used_ctr;
static unsigned int pack_mmap_calls;
static unsigned int peak_pack_open_windows;
static unsigned int pack_open_windows;
static unsigned int pack_open_fds;
static unsigned int pack_max_fds;
static size_t peak_pack_mapped;
static size_t pack_mapped;

#define SZ_FMT
static inline uintmax_t sz_fmt(size_t s) {}

void pack_report(void)
{}

/*
 * Open and mmap the index file at path, perform a couple of
 * consistency checks, then record its information to p.  Return 0 on
 * success.
 */
static int check_packed_git_idx(const char *path, struct packed_git *p)
{}

int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
	     size_t idx_size, struct packed_git *p)
{}

int open_pack_index(struct packed_git *p)
{}

uint32_t get_pack_fanout(struct packed_git *p, uint32_t value)
{}

static struct packed_git *alloc_packed_git(int extra)
{}

static char *pack_path_from_idx(const char *idx_path)
{}

struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path)
{}

static void scan_windows(struct packed_git *p,
	struct packed_git **lru_p,
	struct pack_window **lru_w,
	struct pack_window **lru_l)
{}

static int unuse_one_window(struct packed_git *current)
{}

void close_pack_windows(struct packed_git *p)
{}

int close_pack_fd(struct packed_git *p)
{}

void close_pack_index(struct packed_git *p)
{}

static void close_pack_revindex(struct packed_git *p)
{}

static void close_pack_mtimes(struct packed_git *p)
{}

void close_pack(struct packed_git *p)
{}

void close_object_store(struct raw_object_store *o)
{}

void unlink_pack_path(const char *pack_name, int force_delete)
{}

/*
 * The LRU pack is the one with the oldest MRU window, preferring packs
 * with no used windows, or the oldest mtime if it has no windows allocated.
 */
static void find_lru_pack(struct packed_git *p, struct packed_git **lru_p, struct pack_window **mru_w, int *accept_windows_inuse)
{}

static int close_one_pack(void)
{}

static unsigned int get_max_fd_limit(void)
{}

const char *pack_basename(struct packed_git *p)
{}

/*
 * Do not call this directly as this leaks p->pack_fd on error return;
 * call open_packed_git() instead.
 */
static int open_packed_git_1(struct packed_git *p)
{}

static int open_packed_git(struct packed_git *p)
{}

static int in_window(struct pack_window *win, off_t offset)
{}

unsigned char *use_pack(struct packed_git *p,
		struct pack_window **w_cursor,
		off_t offset,
		unsigned long *left)
{}

void unuse_pack(struct pack_window **w_cursor)
{}

struct packed_git *add_packed_git(const char *path, size_t path_len, int local)
{}

void install_packed_git(struct repository *r, struct packed_git *pack)
{}

void (*report_garbage)(unsigned seen_bits, const char *path);

static void report_helper(const struct string_list *list,
			  int seen_bits, int first, int last)
{}

static void report_pack_garbage(struct string_list *list)
{}

void for_each_file_in_pack_subdir(const char *objdir,
				  const char *subdir,
				  each_file_in_pack_dir_fn fn,
				  void *data)
{}

void for_each_file_in_pack_dir(const char *objdir,
			       each_file_in_pack_dir_fn fn,
			       void *data)
{}

struct prepare_pack_data {};

static void prepare_pack(const char *full_name, size_t full_name_len,
			 const char *file_name, void *_data)
{}

static void prepare_packed_git_one(struct repository *r, char *objdir, int local)
{}

static void prepare_packed_git(struct repository *r);
/*
 * Give a fast, rough count of the number of objects in the repository. This
 * ignores loose objects completely. If you have a lot of them, then either
 * you should repack because your performance will be awful, or they are
 * all unreachable objects about to be pruned, in which case they're not really
 * interesting as a measure of repo size in the first place.
 */
unsigned long repo_approximate_object_count(struct repository *r)
{}

DEFINE_LIST_SORT();

static int sort_pack(const struct packed_git *a, const struct packed_git *b)
{}

static void rearrange_packed_git(struct repository *r)
{}

static void prepare_packed_git_mru(struct repository *r)
{}

static void prepare_packed_git(struct repository *r)
{}

void reprepare_packed_git(struct repository *r)
{}

struct packed_git *get_packed_git(struct repository *r)
{}

struct multi_pack_index *get_multi_pack_index(struct repository *r)
{}

struct multi_pack_index *get_local_multi_pack_index(struct repository *r)
{}

struct packed_git *get_all_packs(struct repository *r)
{}

struct list_head *get_packed_git_mru(struct repository *r)
{}

unsigned long unpack_object_header_buffer(const unsigned char *buf,
		unsigned long len, enum object_type *type, unsigned long *sizep)
{}

unsigned long get_size_from_delta(struct packed_git *p,
				  struct pack_window **w_curs,
				  off_t curpos)
{}

int unpack_object_header(struct packed_git *p,
			 struct pack_window **w_curs,
			 off_t *curpos,
			 unsigned long *sizep)
{}

void mark_bad_packed_object(struct packed_git *p, const struct object_id *oid)
{}

const struct packed_git *has_packed_and_bad(struct repository *r,
					    const struct object_id *oid)
{}

off_t get_delta_base(struct packed_git *p,
		     struct pack_window **w_curs,
		     off_t *curpos,
		     enum object_type type,
		     off_t delta_obj_offset)
{}

/*
 * Like get_delta_base above, but we return the sha1 instead of the pack
 * offset. This means it is cheaper for REF deltas (we do not have to do
 * the final object lookup), but more expensive for OFS deltas (we
 * have to load the revidx to convert the offset back into a sha1).
 */
static int get_delta_base_oid(struct packed_git *p,
			      struct pack_window **w_curs,
			      off_t curpos,
			      struct object_id *oid,
			      enum object_type type,
			      off_t delta_obj_offset)
{}

static int retry_bad_packed_offset(struct repository *r,
				   struct packed_git *p,
				   off_t obj_offset)
{}

#define POI_STACK_PREALLOC

static enum object_type packed_to_object_type(struct repository *r,
					      struct packed_git *p,
					      off_t obj_offset,
					      enum object_type type,
					      struct pack_window **w_curs,
					      off_t curpos)
{}

static struct hashmap delta_base_cache;
static size_t delta_base_cached;

static LIST_HEAD(delta_base_cache_lru);

struct delta_base_cache_key {};

struct delta_base_cache_entry {};

static unsigned int pack_entry_hash(struct packed_git *p, off_t base_offset)
{}

static struct delta_base_cache_entry *
get_delta_base_cache_entry(struct packed_git *p, off_t base_offset)
{}

static int delta_base_cache_key_eq(const struct delta_base_cache_key *a,
				   const struct delta_base_cache_key *b)
{}

static int delta_base_cache_hash_cmp(const void *cmp_data UNUSED,
				     const struct hashmap_entry *va,
				     const struct hashmap_entry *vb,
				     const void *vkey)
{}

static int in_delta_base_cache(struct packed_git *p, off_t base_offset)
{}

/*
 * Remove the entry from the cache, but do _not_ free the associated
 * entry data. The caller takes ownership of the "data" buffer, and
 * should copy out any fields it wants before detaching.
 */
static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)
{}

static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p,
				   off_t base_offset, unsigned long *base_size,
				   enum object_type *type)
{}

static inline void release_delta_base_cache(struct delta_base_cache_entry *ent)
{}

void clear_delta_base_cache(void)
{}

static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
	void *base, unsigned long base_size, enum object_type type)
{}

int packed_object_info(struct repository *r, struct packed_git *p,
		       off_t obj_offset, struct object_info *oi)
{}

static void *unpack_compressed_entry(struct packed_git *p,
				    struct pack_window **w_curs,
				    off_t curpos,
				    unsigned long size)
{}

static void write_pack_access_log(struct packed_git *p, off_t obj_offset)
{}

int do_check_packed_object_crc;

#define UNPACK_ENTRY_STACK_PREALLOC
struct unpack_entry_stack_ent {};

void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
		   enum object_type *final_type, unsigned long *final_size)
{}

int bsearch_pack(const struct object_id *oid, const struct packed_git *p, uint32_t *result)
{}

int nth_packed_object_id(struct object_id *oid,
			 struct packed_git *p,
			 uint32_t n)
{}

void check_pack_index_ptr(const struct packed_git *p, const void *vptr)
{}

off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n)
{}

off_t find_pack_entry_one(const struct object_id *oid,
			  struct packed_git *p)
{}

int is_pack_valid(struct packed_git *p)
{}

struct packed_git *find_oid_pack(const struct object_id *oid,
				 struct packed_git *packs)
{}

static int fill_pack_entry(const struct object_id *oid,
			   struct pack_entry *e,
			   struct packed_git *p)
{}

int find_pack_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e)
{}

static void maybe_invalidate_kept_pack_cache(struct repository *r,
					     unsigned flags)
{}

static struct packed_git **kept_pack_cache(struct repository *r, unsigned flags)
{}

int find_kept_pack_entry(struct repository *r,
			 const struct object_id *oid,
			 unsigned flags,
			 struct pack_entry *e)
{}

int has_object_pack(const struct object_id *oid)
{}

int has_object_kept_pack(const struct object_id *oid, unsigned flags)
{}

int for_each_object_in_pack(struct packed_git *p,
			    each_packed_object_fn cb, void *data,
			    enum for_each_object_flags flags)
{}

int for_each_packed_object(each_packed_object_fn cb, void *data,
			   enum for_each_object_flags flags)
{}

static int add_promisor_object(const struct object_id *oid,
			       struct packed_git *pack UNUSED,
			       uint32_t pos UNUSED,
			       void *set_)
{}

int is_promisor_object(const struct object_id *oid)
{}