git/refs/reftable-backend.c

#define USE_THE_REPOSITORY_VARIABLE

#include "../git-compat-util.h"
#include "../abspath.h"
#include "../chdir-notify.h"
#include "../config.h"
#include "../dir.h"
#include "../environment.h"
#include "../gettext.h"
#include "../hash.h"
#include "../hex.h"
#include "../iterator.h"
#include "../ident.h"
#include "../lockfile.h"
#include "../object.h"
#include "../path.h"
#include "../refs.h"
#include "../reftable/reftable-stack.h"
#include "../reftable/reftable-record.h"
#include "../reftable/reftable-error.h"
#include "../reftable/reftable-iterator.h"
#include "../repo-settings.h"
#include "../setup.h"
#include "../strmap.h"
#include "../trace2.h"
#include "parse.h"
#include "refs-internal.h"

/*
 * Used as a flag in ref_update::flags when the ref_update was via an
 * update to HEAD.
 */
#define REF_UPDATE_VIA_HEAD

struct reftable_ref_store {};

/*
 * Downcast ref_store to reftable_ref_store. Die if ref_store is not a
 * reftable_ref_store. required_flags is compared with ref_store's store_flags
 * to ensure the ref_store has all required capabilities. "caller" is used in
 * any necessary error messages.
 */
static struct reftable_ref_store *reftable_be_downcast(struct ref_store *ref_store,
						       unsigned int required_flags,
						       const char *caller)
{}

/*
 * Some refs are global to the repository (refs/heads/{*}), while others are
 * local to the worktree (eg. HEAD, refs/bisect/{*}). We solve this by having
 * multiple separate databases (ie. multiple reftable/ directories), one for
 * the shared refs, one for the current worktree refs, and one for each
 * additional worktree. For reading, we merge the view of both the shared and
 * the current worktree's refs, when necessary.
 *
 * This function also optionally assigns the rewritten reference name that is
 * local to the stack. This translation is required when using worktree refs
 * like `worktrees/$worktree/refs/heads/foo` as worktree stacks will store
 * those references in their normalized form.
 */
static struct reftable_stack *stack_for(struct reftable_ref_store *store,
					const char *refname,
					const char **rewritten_ref)
{}

static int should_write_log(struct reftable_ref_store *refs, const char *refname)
{}

static void fill_reftable_log_record(struct reftable_log_record *log, const struct ident_split *split)
{}

static int read_ref_without_reload(struct reftable_ref_store *refs,
				   struct reftable_stack *stack,
				   const char *refname,
				   struct object_id *oid,
				   struct strbuf *referent,
				   unsigned int *type)
{}

static int reftable_be_config(const char *var, const char *value,
			      const struct config_context *ctx,
			      void *_opts)
{}

static struct ref_store *reftable_be_init(struct repository *repo,
					  const char *gitdir,
					  unsigned int store_flags)
{}

static void reftable_be_release(struct ref_store *ref_store)
{}

static int reftable_be_create_on_disk(struct ref_store *ref_store,
				      int flags UNUSED,
				      struct strbuf *err UNUSED)
{}

static int reftable_be_remove_on_disk(struct ref_store *ref_store,
				      struct strbuf *err)
{}

struct reftable_ref_iterator {};

/*
 * Handle exclude patterns. Returns either `1`, which tells the caller that the
 * current reference shall not be shown. Or `0`, which indicates that it should
 * be shown.
 */
static int should_exclude_current_ref(struct reftable_ref_iterator *iter)
{}

static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
{}

static int reftable_ref_iterator_peel(struct ref_iterator *ref_iterator,
				      struct object_id *peeled)
{}

static int reftable_ref_iterator_abort(struct ref_iterator *ref_iterator)
{}

static struct ref_iterator_vtable reftable_ref_iterator_vtable =;

static int qsort_strcmp(const void *va, const void *vb)
{}

static char **filter_exclude_patterns(const char **exclude_patterns)
{}

static struct reftable_ref_iterator *ref_iterator_for_stack(struct reftable_ref_store *refs,
							    struct reftable_stack *stack,
							    const char *prefix,
							    const char **exclude_patterns,
							    int flags)
{}

static struct ref_iterator *reftable_be_iterator_begin(struct ref_store *ref_store,
						       const char *prefix,
						       const char **exclude_patterns,
						       unsigned int flags)
{}

static int reftable_be_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 reftable_be_read_symbolic_ref(struct ref_store *ref_store,
					 const char *refname,
					 struct strbuf *referent)
{}

struct reftable_transaction_update {};

struct write_transaction_table_arg {};

struct reftable_transaction_data {};

static void free_transaction_data(struct reftable_transaction_data *tx_data)
{}

/*
 * Prepare transaction update for the given reference update. This will cause
 * us to lock the corresponding reftable stack for concurrent modification.
 */
static int prepare_transaction_update(struct write_transaction_table_arg **out,
				      struct reftable_ref_store *refs,
				      struct reftable_transaction_data *tx_data,
				      struct ref_update *update,
				      struct strbuf *err)
{}

/*
 * Queue a reference update for the correct stack. We potentially need to
 * handle multiple stack updates in a single transaction when it spans across
 * multiple worktrees.
 */
static int queue_transaction_update(struct reftable_ref_store *refs,
				    struct reftable_transaction_data *tx_data,
				    struct ref_update *update,
				    struct object_id *current_oid,
				    struct strbuf *err)
{}

static int reftable_be_transaction_prepare(struct ref_store *ref_store,
					   struct ref_transaction *transaction,
					   struct strbuf *err)
{}

static int reftable_be_transaction_abort(struct ref_store *ref_store UNUSED,
					 struct ref_transaction *transaction,
					 struct strbuf *err UNUSED)
{}

static int transaction_update_cmp(const void *a, const void *b)
{}

static int write_transaction_table(struct reftable_writer *writer, void *cb_data)
{}

static int reftable_be_transaction_finish(struct ref_store *ref_store UNUSED,
					  struct ref_transaction *transaction,
					  struct strbuf *err)
{}

static int reftable_be_initial_transaction_commit(struct ref_store *ref_store UNUSED,
						  struct ref_transaction *transaction,
						  struct strbuf *err)
{}

static int reftable_be_pack_refs(struct ref_store *ref_store,
				 struct pack_refs_opts *opts)
{}

struct write_create_symref_arg {};

struct write_copy_arg {};

static int write_copy_table(struct reftable_writer *writer, void *cb_data)
{}

static int reftable_be_rename_ref(struct ref_store *ref_store,
				  const char *oldrefname,
				  const char *newrefname,
				  const char *logmsg)
{}

static int reftable_be_copy_ref(struct ref_store *ref_store,
				const char *oldrefname,
				const char *newrefname,
				const char *logmsg)
{}

struct reftable_reflog_iterator {};

static int reftable_reflog_iterator_advance(struct ref_iterator *ref_iterator)
{}

static int reftable_reflog_iterator_peel(struct ref_iterator *ref_iterator UNUSED,
					 struct object_id *peeled UNUSED)
{}

static int reftable_reflog_iterator_abort(struct ref_iterator *ref_iterator)
{}

static struct ref_iterator_vtable reftable_reflog_iterator_vtable =;

static struct reftable_reflog_iterator *reflog_iterator_for_stack(struct reftable_ref_store *refs,
								  struct reftable_stack *stack)
{}

static struct ref_iterator *reftable_be_reflog_iterator_begin(struct ref_store *ref_store)
{}

static int yield_log_record(struct reftable_ref_store *refs,
			    struct reftable_log_record *log,
			    each_reflog_ent_fn fn,
			    void *cb_data)
{}

static int reftable_be_for_each_reflog_ent_reverse(struct ref_store *ref_store,
						   const char *refname,
						   each_reflog_ent_fn fn,
						   void *cb_data)
{}

static int reftable_be_for_each_reflog_ent(struct ref_store *ref_store,
					   const char *refname,
					   each_reflog_ent_fn fn,
					   void *cb_data)
{}

static int reftable_be_reflog_exists(struct ref_store *ref_store,
				     const char *refname)
{}

struct write_reflog_existence_arg {};

static int write_reflog_existence_table(struct reftable_writer *writer,
					void *cb_data)
{}

static int reftable_be_create_reflog(struct ref_store *ref_store,
				     const char *refname,
				     struct strbuf *errmsg UNUSED)
{}

struct write_reflog_delete_arg {};

static int write_reflog_delete_table(struct reftable_writer *writer, void *cb_data)
{}

static int reftable_be_delete_reflog(struct ref_store *ref_store,
				     const char *refname)
{}

struct reflog_expiry_arg {};

static int write_reflog_expiry_table(struct reftable_writer *writer, void *cb_data)
{}

static int reftable_be_reflog_expire(struct ref_store *ref_store,
				     const char *refname,
				     unsigned int 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 reftable_be_fsck(struct ref_store *ref_store UNUSED,
			    struct fsck_options *o UNUSED)
{}

struct ref_storage_be refs_be_reftable =;