#define USE_THE_REPOSITORY_VARIABLE
#include "../git-compat-util.h"
#include "../config.h"
#include "../copy.h"
#include "../environment.h"
#include "../gettext.h"
#include "../hash.h"
#include "../hex.h"
#include "../fsck.h"
#include "../refs.h"
#include "../repo-settings.h"
#include "refs-internal.h"
#include "ref-cache.h"
#include "packed-backend.h"
#include "../ident.h"
#include "../iterator.h"
#include "../dir-iterator.h"
#include "../lockfile.h"
#include "../object.h"
#include "../object-file.h"
#include "../path.h"
#include "../dir.h"
#include "../chdir-notify.h"
#include "../setup.h"
#include "../wrapper.h"
#include "../write-or-die.h"
#include "../revision.h"
#include <wildmatch.h>
#define REF_IS_PRUNING …
#define REF_DELETING …
#define REF_NEEDS_COMMIT …
#define REF_UPDATE_VIA_HEAD …
#define REF_DELETED_RMDIR …
struct ref_lock { … };
struct files_ref_store { … };
static void clear_loose_ref_cache(struct files_ref_store *refs)
{ … }
static struct ref_store *files_ref_store_init(struct repository *repo,
const char *gitdir,
unsigned int flags)
{ … }
static void files_assert_main_repository(struct files_ref_store *refs,
const char *caller)
{ … }
static struct files_ref_store *files_downcast(struct ref_store *ref_store,
unsigned int required_flags,
const char *caller)
{ … }
static void files_ref_store_release(struct ref_store *ref_store)
{ … }
static void files_reflog_path(struct files_ref_store *refs,
struct strbuf *sb,
const char *refname)
{ … }
static void files_ref_path(struct files_ref_store *refs,
struct strbuf *sb,
const char *refname)
{ … }
static void add_per_worktree_entries_to_dir(struct ref_dir *dir, const char *dirname)
{ … }
static void loose_fill_ref_dir_regular_file(struct files_ref_store *refs,
const char *refname,
struct ref_dir *dir)
{ … }
static void loose_fill_ref_dir(struct ref_store *ref_store,
struct ref_dir *dir, const char *dirname)
{ … }
static int for_each_root_ref(struct files_ref_store *refs,
int (*cb)(const char *refname, void *cb_data),
void *cb_data)
{ … }
struct fill_root_ref_data { … };
static int fill_root_ref(const char *refname, void *cb_data)
{ … }
static void add_root_refs(struct files_ref_store *refs,
struct ref_dir *dir)
{ … }
static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs,
unsigned int flags)
{ … }
static int read_ref_internal(struct ref_store *ref_store, const char *refname,
struct object_id *oid, struct strbuf *referent,
unsigned int *type, int *failure_errno, int skip_packed_refs)
{ … }
static int files_read_raw_ref(struct ref_store *ref_store, const char *refname,
struct object_id *oid, struct strbuf *referent,
unsigned int *type, int *failure_errno)
{ … }
static int files_read_symbolic_ref(struct ref_store *ref_store, const char *refname,
struct strbuf *referent)
{ … }
int parse_loose_ref_contents(const struct git_hash_algo *algop,
const char *buf, struct object_id *oid,
struct strbuf *referent, unsigned int *type,
int *failure_errno)
{ … }
static void unlock_ref(struct ref_lock *lock)
{ … }
static int lock_raw_ref(struct files_ref_store *refs,
const char *refname, int mustexist,
const struct string_list *extras,
struct ref_lock **lock_p,
struct strbuf *referent,
unsigned int *type,
struct strbuf *err)
{ … }
struct files_ref_iterator { … };
static int files_ref_iterator_advance(struct ref_iterator *ref_iterator)
{ … }
static int files_ref_iterator_peel(struct ref_iterator *ref_iterator,
struct object_id *peeled)
{ … }
static int files_ref_iterator_abort(struct ref_iterator *ref_iterator)
{ … }
static struct ref_iterator_vtable files_ref_iterator_vtable = …;
static struct ref_iterator *files_ref_iterator_begin(
struct ref_store *ref_store,
const char *prefix, const char **exclude_patterns,
unsigned int flags)
{ … }
create_file_fn;
static int raceproof_create_file(const char *path, create_file_fn fn, void *cb)
{ … }
static int remove_empty_directories(struct strbuf *path)
{ … }
static int create_reflock(const char *path, void *cb)
{ … }
static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,
const char *refname,
struct strbuf *err)
{ … }
struct ref_to_prune { … };
enum { … };
static void try_remove_empty_parents(struct files_ref_store *refs,
const char *refname,
unsigned int flags)
{ … }
static void prune_ref(struct files_ref_store *refs, struct ref_to_prune *r)
{ … }
static void prune_refs(struct files_ref_store *refs, struct ref_to_prune **refs_to_prune)
{ … }
static int should_pack_ref(struct files_ref_store *refs,
const char *refname,
const struct object_id *oid, unsigned int ref_flags,
struct pack_refs_opts *opts)
{ … }
static int should_pack_refs(struct files_ref_store *refs,
struct pack_refs_opts *opts)
{ … }
static int files_pack_refs(struct ref_store *ref_store,
struct pack_refs_opts *opts)
{ … }
#define TMP_RENAMED_LOG …
struct rename_cb { … };
static int rename_tmp_log_callback(const char *path, void *cb_data)
{ … }
static int rename_tmp_log(struct files_ref_store *refs, const char *newrefname)
{ … }
static int write_ref_to_lockfile(struct files_ref_store *refs,
struct ref_lock *lock,
const struct object_id *oid,
int skip_oid_verification, struct strbuf *err);
static int commit_ref_update(struct files_ref_store *refs,
struct ref_lock *lock,
const struct object_id *oid, const char *logmsg,
int flags,
struct strbuf *err);
static int refs_rename_ref_available(struct ref_store *refs,
const char *old_refname,
const char *new_refname)
{ … }
static int files_copy_or_rename_ref(struct ref_store *ref_store,
const char *oldrefname, const char *newrefname,
const char *logmsg, int copy)
{ … }
static int files_rename_ref(struct ref_store *ref_store,
const char *oldrefname, const char *newrefname,
const char *logmsg)
{ … }
static int files_copy_ref(struct ref_store *ref_store,
const char *oldrefname, const char *newrefname,
const char *logmsg)
{ … }
static int close_ref_gently(struct ref_lock *lock)
{ … }
static int commit_ref(struct ref_lock *lock)
{ … }
static int open_or_create_logfile(const char *path, void *cb)
{ … }
static int log_ref_setup(struct files_ref_store *refs,
const char *refname, int force_create,
int *logfd, struct strbuf *err)
{ … }
static int files_create_reflog(struct ref_store *ref_store, const char *refname,
struct strbuf *err)
{ … }
static int log_ref_write_fd(int fd, const struct object_id *old_oid,
const struct object_id *new_oid,
const char *committer, const char *msg)
{ … }
static int files_log_ref_write(struct files_ref_store *refs,
const char *refname, const struct object_id *old_oid,
const struct object_id *new_oid, const char *msg,
int flags, struct strbuf *err)
{ … }
static int write_ref_to_lockfile(struct files_ref_store *refs,
struct ref_lock *lock,
const struct object_id *oid,
int skip_oid_verification, struct strbuf *err)
{ … }
static int commit_ref_update(struct files_ref_store *refs,
struct ref_lock *lock,
const struct object_id *oid, const char *logmsg,
int flags,
struct strbuf *err)
{ … }
#ifdef NO_SYMLINK_HEAD
#define create_ref_symlink …
#else
static int create_ref_symlink(struct ref_lock *lock, const char *target)
{ … }
#endif
static int create_symref_lock(struct ref_lock *lock, const char *target,
struct strbuf *err)
{ … }
static int files_reflog_exists(struct ref_store *ref_store,
const char *refname)
{ … }
static int files_delete_reflog(struct ref_store *ref_store,
const char *refname)
{ … }
static int show_one_reflog_ent(struct files_ref_store *refs, struct strbuf *sb,
each_reflog_ent_fn fn, void *cb_data)
{ … }
static char *find_beginning_of_line(char *bob, char *scan)
{ … }
static int files_for_each_reflog_ent_reverse(struct ref_store *ref_store,
const char *refname,
each_reflog_ent_fn fn,
void *cb_data)
{ … }
static int files_for_each_reflog_ent(struct ref_store *ref_store,
const char *refname,
each_reflog_ent_fn fn, void *cb_data)
{ … }
struct files_reflog_iterator { … };
static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
{ … }
static int files_reflog_iterator_peel(struct ref_iterator *ref_iterator UNUSED,
struct object_id *peeled UNUSED)
{ … }
static int files_reflog_iterator_abort(struct ref_iterator *ref_iterator)
{ … }
static struct ref_iterator_vtable files_reflog_iterator_vtable = …;
static struct ref_iterator *reflog_iterator_begin(struct ref_store *ref_store,
const char *gitdir)
{ … }
static struct ref_iterator *files_reflog_iterator_begin(struct ref_store *ref_store)
{ … }
static int split_head_update(struct ref_update *update,
struct ref_transaction *transaction,
const char *head_ref,
struct string_list *affected_refnames,
struct strbuf *err)
{ … }
static int split_symref_update(struct ref_update *update,
const char *referent,
struct ref_transaction *transaction,
struct string_list *affected_refnames,
struct strbuf *err)
{ … }
static int check_old_oid(struct ref_update *update, struct object_id *oid,
struct strbuf *err)
{ … }
static int lock_ref_for_update(struct files_ref_store *refs,
struct ref_update *update,
struct ref_transaction *transaction,
const char *head_ref,
struct string_list *affected_refnames,
struct strbuf *err)
{ … }
struct files_transaction_backend_data { … };
static void files_transaction_cleanup(struct files_ref_store *refs,
struct ref_transaction *transaction)
{ … }
static int files_transaction_prepare(struct ref_store *ref_store,
struct ref_transaction *transaction,
struct strbuf *err)
{ … }
static int parse_and_write_reflog(struct files_ref_store *refs,
struct ref_update *update,
struct ref_lock *lock,
struct strbuf *err)
{ … }
static int files_transaction_finish(struct ref_store *ref_store,
struct ref_transaction *transaction,
struct strbuf *err)
{ … }
static int files_transaction_abort(struct ref_store *ref_store,
struct ref_transaction *transaction,
struct strbuf *err UNUSED)
{ … }
static int ref_present(const char *refname, const char *referent UNUSED,
const struct object_id *oid UNUSED,
int flags UNUSED,
void *cb_data)
{ … }
static int files_initial_transaction_commit(struct ref_store *ref_store,
struct ref_transaction *transaction,
struct strbuf *err)
{ … }
struct expire_reflog_cb { … };
static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
const char *email, timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{ … }
static int files_reflog_expire(struct ref_store *ref_store,
const char *refname,
unsigned int expire_flags,
reflog_expiry_prepare_fn prepare_fn,
reflog_expiry_should_prune_fn should_prune_fn,
reflog_expiry_cleanup_fn cleanup_fn,
void *policy_cb_data)
{ … }
static int files_ref_store_create_on_disk(struct ref_store *ref_store,
int flags,
struct strbuf *err UNUSED)
{ … }
struct remove_one_root_ref_data { … };
static int remove_one_root_ref(const char *refname,
void *cb_data)
{ … }
static int files_ref_store_remove_on_disk(struct ref_store *ref_store,
struct strbuf *err)
{ … }
files_fsck_refs_fn;
static int files_fsck_refs_name(struct ref_store *ref_store UNUSED,
struct fsck_options *o,
const char *refs_check_dir,
struct dir_iterator *iter)
{ … }
static int files_fsck_refs_dir(struct ref_store *ref_store,
struct fsck_options *o,
const char *refs_check_dir,
files_fsck_refs_fn *fsck_refs_fn)
{ … }
static int files_fsck_refs(struct ref_store *ref_store,
struct fsck_options *o)
{ … }
static int files_fsck(struct ref_store *ref_store,
struct fsck_options *o)
{ … }
struct ref_storage_be refs_be_files = …;