#define USE_THE_REPOSITORY_VARIABLE
#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
#include "convert.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "string-list.h"
#include "lockfile.h"
#include "pack.h"
#include "commit.h"
#include "run-command.h"
#include "refs.h"
#include "bulk-checkin.h"
#include "repository.h"
#include "replace-object.h"
#include "streaming.h"
#include "dir.h"
#include "list.h"
#include "quote.h"
#include "packfile.h"
#include "object-file.h"
#include "object-store.h"
#include "oidtree.h"
#include "path.h"
#include "promisor-remote.h"
#include "setup.h"
#include "submodule.h"
#include "fsck.h"
#include "loose.h"
#include "object-file-convert.h"
#define MAX_HEADER_LEN …
#define EMPTY_TREE_SHA1_BIN_LITERAL …
#define EMPTY_TREE_SHA256_BIN_LITERAL …
#define EMPTY_BLOB_SHA1_BIN_LITERAL …
#define EMPTY_BLOB_SHA256_BIN_LITERAL …
static const struct object_id empty_tree_oid = …;
static const struct object_id empty_blob_oid = …;
static const struct object_id null_oid_sha1 = …;
static const struct object_id empty_tree_oid_sha256 = …;
static const struct object_id empty_blob_oid_sha256 = …;
static const struct object_id null_oid_sha256 = …;
static void git_hash_sha1_init(git_hash_ctx *ctx)
{ … }
static void git_hash_sha1_clone(git_hash_ctx *dst, const git_hash_ctx *src)
{ … }
static void git_hash_sha1_update(git_hash_ctx *ctx, const void *data, size_t len)
{ … }
static void git_hash_sha1_final(unsigned char *hash, git_hash_ctx *ctx)
{ … }
static void git_hash_sha1_final_oid(struct object_id *oid, git_hash_ctx *ctx)
{ … }
static void git_hash_sha1_init_unsafe(git_hash_ctx *ctx)
{ … }
static void git_hash_sha1_clone_unsafe(git_hash_ctx *dst, const git_hash_ctx *src)
{ … }
static void git_hash_sha1_update_unsafe(git_hash_ctx *ctx, const void *data,
size_t len)
{ … }
static void git_hash_sha1_final_unsafe(unsigned char *hash, git_hash_ctx *ctx)
{ … }
static void git_hash_sha1_final_oid_unsafe(struct object_id *oid, git_hash_ctx *ctx)
{ … }
static void git_hash_sha256_init(git_hash_ctx *ctx)
{ … }
static void git_hash_sha256_clone(git_hash_ctx *dst, const git_hash_ctx *src)
{ … }
static void git_hash_sha256_update(git_hash_ctx *ctx, const void *data, size_t len)
{ … }
static void git_hash_sha256_final(unsigned char *hash, git_hash_ctx *ctx)
{ … }
static void git_hash_sha256_final_oid(struct object_id *oid, git_hash_ctx *ctx)
{ … }
static void git_hash_unknown_init(git_hash_ctx *ctx UNUSED)
{ … }
static void git_hash_unknown_clone(git_hash_ctx *dst UNUSED,
const git_hash_ctx *src UNUSED)
{ … }
static void git_hash_unknown_update(git_hash_ctx *ctx UNUSED,
const void *data UNUSED,
size_t len UNUSED)
{ … }
static void git_hash_unknown_final(unsigned char *hash UNUSED,
git_hash_ctx *ctx UNUSED)
{ … }
static void git_hash_unknown_final_oid(struct object_id *oid UNUSED,
git_hash_ctx *ctx UNUSED)
{ … }
const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = …;
const struct object_id *null_oid(void)
{ … }
const char *empty_tree_oid_hex(const struct git_hash_algo *algop)
{ … }
int hash_algo_by_name(const char *name)
{ … }
int hash_algo_by_id(uint32_t format_id)
{ … }
int hash_algo_by_length(int len)
{ … }
static struct cached_object { … } *cached_objects;
static int cached_object_nr, cached_object_alloc;
static struct cached_object empty_tree = …;
static struct cached_object *find_cached_object(const struct object_id *oid)
{ … }
static int get_conv_flags(unsigned flags)
{ … }
int mkdir_in_gitdir(const char *path)
{ … }
static enum scld_error safe_create_leading_directories_1(char *path, int share)
{ … }
enum scld_error safe_create_leading_directories(char *path)
{ … }
enum scld_error safe_create_leading_directories_no_share(char *path)
{ … }
enum scld_error safe_create_leading_directories_const(const char *path)
{ … }
int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)
{ … }
int odb_pack_keep(const char *name)
{ … }
static void fill_loose_path(struct strbuf *buf, const struct object_id *oid)
{ … }
static const char *odb_loose_path(struct object_directory *odb,
struct strbuf *buf,
const struct object_id *oid)
{ … }
const char *loose_object_path(struct repository *r, struct strbuf *buf,
const struct object_id *oid)
{ … }
static int alt_odb_usable(struct raw_object_store *o,
struct strbuf *path,
const char *normalized_objdir, khiter_t *pos)
{ … }
static void read_info_alternates(struct repository *r,
const char *relative_base,
int depth);
static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,
const char *relative_base, int depth, const char *normalized_objdir)
{ … }
static const char *parse_alt_odb_entry(const char *string,
int sep,
struct strbuf *out)
{ … }
static void link_alt_odb_entries(struct repository *r, const char *alt,
int sep, const char *relative_base, int depth)
{ … }
static void read_info_alternates(struct repository *r,
const char *relative_base,
int depth)
{ … }
void add_to_alternates_file(const char *reference)
{ … }
void add_to_alternates_memory(const char *reference)
{ … }
struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy)
{ … }
void restore_primary_odb(struct object_directory *restore_odb, const char *old_path)
{ … }
char *compute_alternate_path(const char *path, struct strbuf *err)
{ … }
struct object_directory *find_odb(struct repository *r, const char *obj_dir)
{ … }
static void fill_alternate_refs_command(struct child_process *cmd,
const char *repo_path)
{ … }
static void read_alternate_refs(const char *path,
alternate_ref_fn *cb,
void *data)
{ … }
struct alternate_refs_data { … };
static int refs_from_alternate_cb(struct object_directory *e,
void *data)
{ … }
void for_each_alternate_ref(alternate_ref_fn fn, void *data)
{ … }
int foreach_alt_odb(alt_odb_fn fn, void *cb)
{ … }
void prepare_alt_odb(struct repository *r)
{ … }
int has_alt_odb(struct repository *r)
{ … }
static int freshen_file(const char *fn)
{ … }
int check_and_freshen_file(const char *fn, int freshen)
{ … }
static int check_and_freshen_odb(struct object_directory *odb,
const struct object_id *oid,
int freshen)
{ … }
static int check_and_freshen_local(const struct object_id *oid, int freshen)
{ … }
static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)
{ … }
static int check_and_freshen(const struct object_id *oid, int freshen)
{ … }
int has_loose_object_nonlocal(const struct object_id *oid)
{ … }
int has_loose_object(const struct object_id *oid)
{ … }
static void mmap_limit_check(size_t length)
{ … }
void *xmmap_gently(void *start, size_t length,
int prot, int flags, int fd, off_t offset)
{ … }
const char *mmap_os_err(void)
{ … }
void *xmmap(void *start, size_t length,
int prot, int flags, int fd, off_t offset)
{ … }
static int format_object_header_literally(char *str, size_t size,
const char *type, size_t objsize)
{ … }
int format_object_header(char *str, size_t size, enum object_type type,
size_t objsize)
{ … }
int check_object_signature(struct repository *r, const struct object_id *oid,
void *buf, unsigned long size,
enum object_type type)
{ … }
int stream_object_signature(struct repository *r, const struct object_id *oid)
{ … }
int git_open_cloexec(const char *name, int flags)
{ … }
static int stat_loose_object(struct repository *r, const struct object_id *oid,
struct stat *st, const char **path)
{ … }
static int open_loose_object(struct repository *r,
const struct object_id *oid, const char **path)
{ … }
static int quick_has_loose(struct repository *r,
const struct object_id *oid)
{ … }
static void *map_fd(int fd, const char *path, unsigned long *size)
{ … }
void *map_loose_object(struct repository *r,
const struct object_id *oid,
unsigned long *size)
{ … }
enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
unsigned char *map,
unsigned long mapsize,
void *buffer,
unsigned long bufsiz,
struct strbuf *header)
{ … }
static void *unpack_loose_rest(git_zstream *stream,
void *buffer, unsigned long size,
const struct object_id *oid)
{ … }
int parse_loose_header(const char *hdr, struct object_info *oi)
{ … }
static int loose_object_info(struct repository *r,
const struct object_id *oid,
struct object_info *oi, int flags)
{ … }
int obj_read_use_lock = …;
pthread_mutex_t obj_read_mutex;
void enable_obj_read_lock(void)
{ … }
void disable_obj_read_lock(void)
{ … }
int fetch_if_missing = …;
static int do_oid_object_info_extended(struct repository *r,
const struct object_id *oid,
struct object_info *oi, unsigned flags)
{ … }
static int oid_object_info_convert(struct repository *r,
const struct object_id *input_oid,
struct object_info *input_oi, unsigned flags)
{ … }
int oid_object_info_extended(struct repository *r, const struct object_id *oid,
struct object_info *oi, unsigned flags)
{ … }
int oid_object_info(struct repository *r,
const struct object_id *oid,
unsigned long *sizep)
{ … }
int pretend_object_file(void *buf, unsigned long len, enum object_type type,
struct object_id *oid)
{ … }
void *repo_read_object_file(struct repository *r,
const struct object_id *oid,
enum object_type *type,
unsigned long *size)
{ … }
void *read_object_with_reference(struct repository *r,
const struct object_id *oid,
enum object_type required_type,
unsigned long *size,
struct object_id *actual_oid_return)
{ … }
static void hash_object_body(const struct git_hash_algo *algo, git_hash_ctx *c,
const void *buf, unsigned long len,
struct object_id *oid,
char *hdr, int *hdrlen)
{ … }
static void write_object_file_prepare(const struct git_hash_algo *algo,
const void *buf, unsigned long len,
enum object_type type, struct object_id *oid,
char *hdr, int *hdrlen)
{ … }
static void write_object_file_prepare_literally(const struct git_hash_algo *algo,
const void *buf, unsigned long len,
const char *type, struct object_id *oid,
char *hdr, int *hdrlen)
{ … }
static int check_collision(const char *filename_a, const char *filename_b)
{ … }
int finalize_object_file(const char *tmpfile, const char *filename)
{ … }
int finalize_object_file_flags(const char *tmpfile, const char *filename,
enum finalize_object_file_flags flags)
{ … }
static void hash_object_file_literally(const struct git_hash_algo *algo,
const void *buf, unsigned long len,
const char *type, struct object_id *oid)
{ … }
void hash_object_file(const struct git_hash_algo *algo, const void *buf,
unsigned long len, enum object_type type,
struct object_id *oid)
{ … }
static void close_loose_object(int fd, const char *filename)
{ … }
static inline int directory_size(const char *filename)
{ … }
static int create_tmpfile(struct strbuf *tmp, const char *filename)
{ … }
static int start_loose_object_common(struct strbuf *tmp_file,
const char *filename, unsigned flags,
git_zstream *stream,
unsigned char *buf, size_t buflen,
git_hash_ctx *c, git_hash_ctx *compat_c,
char *hdr, int hdrlen)
{ … }
static int write_loose_object_common(git_hash_ctx *c, git_hash_ctx *compat_c,
git_zstream *stream, const int flush,
unsigned char *in0, const int fd,
unsigned char *compressed,
const size_t compressed_len)
{ … }
static int end_loose_object_common(git_hash_ctx *c, git_hash_ctx *compat_c,
git_zstream *stream, struct object_id *oid,
struct object_id *compat_oid)
{ … }
static int write_loose_object(const struct object_id *oid, char *hdr,
int hdrlen, const void *buf, unsigned long len,
time_t mtime, unsigned flags)
{ … }
static int freshen_loose_object(const struct object_id *oid)
{ … }
static int freshen_packed_object(const struct object_id *oid)
{ … }
int stream_loose_object(struct input_stream *in_stream, size_t len,
struct object_id *oid)
{ … }
int write_object_file_flags(const void *buf, unsigned long len,
enum object_type type, struct object_id *oid,
struct object_id *compat_oid_in, unsigned flags)
{ … }
int write_object_file_literally(const void *buf, unsigned long len,
const char *type, struct object_id *oid,
unsigned flags)
{ … }
int force_object_loose(const struct object_id *oid, time_t mtime)
{ … }
int has_object(struct repository *r, const struct object_id *oid,
unsigned flags)
{ … }
int repo_has_object_file_with_flags(struct repository *r,
const struct object_id *oid, int flags)
{ … }
int repo_has_object_file(struct repository *r,
const struct object_id *oid)
{ … }
static int hash_format_check_report(struct fsck_options *opts UNUSED,
void *fsck_report UNUSED,
enum fsck_msg_type msg_type UNUSED,
enum fsck_msg_id msg_id UNUSED,
const char *message)
{ … }
static int index_mem(struct index_state *istate,
struct object_id *oid,
const void *buf, size_t size,
enum object_type type,
const char *path, unsigned flags)
{ … }
static int index_stream_convert_blob(struct index_state *istate,
struct object_id *oid,
int fd,
const char *path,
unsigned flags)
{ … }
static int index_pipe(struct index_state *istate, struct object_id *oid,
int fd, enum object_type type,
const char *path, unsigned flags)
{ … }
#define SMALL_FILE_SIZE …
static int index_core(struct index_state *istate,
struct object_id *oid, int fd, size_t size,
enum object_type type, const char *path,
unsigned flags)
{ … }
static int index_blob_stream(struct object_id *oid, int fd, size_t size,
const char *path,
unsigned flags)
{ … }
int index_fd(struct index_state *istate, struct object_id *oid,
int fd, struct stat *st,
enum object_type type, const char *path, unsigned flags)
{ … }
int index_path(struct index_state *istate, struct object_id *oid,
const char *path, struct stat *st, unsigned flags)
{ … }
int read_pack_header(int fd, struct pack_header *header)
{ … }
void assert_oid_type(const struct object_id *oid, enum object_type expect)
{ … }
int for_each_file_in_obj_subdir(unsigned int subdir_nr,
struct strbuf *path,
each_loose_object_fn obj_cb,
each_loose_cruft_fn cruft_cb,
each_loose_subdir_fn subdir_cb,
void *data)
{ … }
int for_each_loose_file_in_objdir_buf(struct strbuf *path,
each_loose_object_fn obj_cb,
each_loose_cruft_fn cruft_cb,
each_loose_subdir_fn subdir_cb,
void *data)
{ … }
int for_each_loose_file_in_objdir(const char *path,
each_loose_object_fn obj_cb,
each_loose_cruft_fn cruft_cb,
each_loose_subdir_fn subdir_cb,
void *data)
{ … }
int for_each_loose_object(each_loose_object_fn cb, void *data,
enum for_each_object_flags flags)
{ … }
static int append_loose_object(const struct object_id *oid,
const char *path UNUSED,
void *data)
{ … }
struct oidtree *odb_loose_cache(struct object_directory *odb,
const struct object_id *oid)
{ … }
void odb_clear_loose_cache(struct object_directory *odb)
{ … }
static int check_stream_oid(git_zstream *stream,
const char *hdr,
unsigned long size,
const char *path,
const struct object_id *expected_oid)
{ … }
int read_loose_object(const char *path,
const struct object_id *expected_oid,
struct object_id *real_oid,
void **contents,
struct object_info *oi)
{ … }