#define USE_THE_REPOSITORY_VARIABLE
#include "git-compat-util.h"
#include "advice.h"
#include "config.h"
#include "environment.h"
#include "strmap.h"
#include "gettext.h"
#include "hex.h"
#include "lockfile.h"
#include "iterator.h"
#include "refs.h"
#include "refs/refs-internal.h"
#include "run-command.h"
#include "hook.h"
#include "object-name.h"
#include "object-store-ll.h"
#include "object.h"
#include "path.h"
#include "submodule.h"
#include "worktree.h"
#include "strvec.h"
#include "repo-settings.h"
#include "setup.h"
#include "sigchain.h"
#include "date.h"
#include "commit.h"
#include "wildmatch.h"
static const struct ref_storage_be *refs_backends[] = …;
static const struct ref_storage_be *find_ref_storage_backend(
enum ref_storage_format ref_storage_format)
{ … }
enum ref_storage_format ref_storage_format_by_name(const char *name)
{ … }
const char *ref_storage_format_to_name(enum ref_storage_format ref_storage_format)
{ … }
static unsigned char refname_disposition[256] = …;
struct ref_namespace_info ref_namespace[] = …;
void update_ref_namespace(enum ref_namespace namespace, char *ref)
{ … }
static int check_refname_component(const char *refname, int *flags,
struct strbuf *sanitized)
{ … }
static int check_or_sanitize_refname(const char *refname, int flags,
struct strbuf *sanitized)
{ … }
int check_refname_format(const char *refname, int flags)
{ … }
int refs_fsck(struct ref_store *refs, struct fsck_options *o)
{ … }
void sanitize_refname_component(const char *refname, struct strbuf *out)
{ … }
int refname_is_safe(const char *refname)
{ … }
int ref_resolves_to_object(const char *refname,
struct repository *repo,
const struct object_id *oid,
unsigned int flags)
{ … }
char *refs_resolve_refdup(struct ref_store *refs,
const char *refname, int resolve_flags,
struct object_id *oid, int *flags)
{ … }
struct for_each_ref_filter { … };
int refs_read_ref_full(struct ref_store *refs, const char *refname,
int resolve_flags, struct object_id *oid, int *flags)
{ … }
int refs_read_ref(struct ref_store *refs, const char *refname, struct object_id *oid)
{ … }
int refs_ref_exists(struct ref_store *refs, const char *refname)
{ … }
static int for_each_filter_refs(const char *refname, const char *referent,
const struct object_id *oid,
int flags, void *data)
{ … }
struct warn_if_dangling_data { … };
static int warn_if_dangling_symref(const char *refname, const char *referent UNUSED,
const struct object_id *oid UNUSED,
int flags, void *cb_data)
{ … }
void refs_warn_dangling_symref(struct ref_store *refs, FILE *fp,
const char *msg_fmt, const char *refname)
{ … }
void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp,
const char *msg_fmt, const struct string_list *refnames)
{ … }
int refs_for_each_tag_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{ … }
int refs_for_each_branch_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{ … }
int refs_for_each_remote_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{ … }
int refs_head_ref_namespaced(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{ … }
void normalize_glob_ref(struct string_list_item *item, const char *prefix,
const char *pattern)
{ … }
int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn,
const char *pattern, const char *prefix, void *cb_data)
{ … }
int refs_for_each_glob_ref(struct ref_store *refs, each_ref_fn fn,
const char *pattern, void *cb_data)
{ … }
const char *prettify_refname(const char *name)
{ … }
static const char *ref_rev_parse_rules[] = …;
#define NUM_REV_PARSE_RULES …
int refname_match(const char *abbrev_name, const char *full_name)
{ … }
void expand_ref_prefix(struct strvec *prefixes, const char *prefix)
{ … }
static const char default_branch_name_advice[] = …
);
char *repo_default_branch_name(struct repository *r, int quiet)
{ … }
static char *substitute_branch_name(struct repository *r,
const char **string, int *len,
int nonfatal_dangling_mark)
{ … }
int repo_dwim_ref(struct repository *r, const char *str, int len,
struct object_id *oid, char **ref, int nonfatal_dangling_mark)
{ … }
int expand_ref(struct repository *repo, const char *str, int len,
struct object_id *oid, char **ref)
{ … }
int repo_dwim_log(struct repository *r, const char *str, int len,
struct object_id *oid, char **log)
{ … }
int is_per_worktree_ref(const char *refname)
{ … }
int is_pseudo_ref(const char *refname)
{ … }
static int is_root_ref_syntax(const char *refname)
{ … }
int is_root_ref(const char *refname)
{ … }
static int is_current_worktree_ref(const char *ref) { … }
enum ref_worktree_type parse_worktree_ref(const char *maybe_worktree_ref,
const char **worktree_name, int *worktree_name_length,
const char **bare_refname)
{ … }
long get_files_ref_lock_timeout_ms(void)
{ … }
int refs_delete_ref(struct ref_store *refs, const char *msg,
const char *refname,
const struct object_id *old_oid,
unsigned int flags)
{ … }
static void copy_reflog_msg(struct strbuf *sb, const char *msg)
{ … }
static char *normalize_reflog_message(const char *msg)
{ … }
int should_autocreate_reflog(enum log_refs_config log_all_ref_updates,
const char *refname)
{ … }
int is_branch(const char *refname)
{ … }
struct read_ref_at_cb { … };
static void set_read_ref_cutoffs(struct read_ref_at_cb *cb,
timestamp_t timestamp, int tz, const char *message)
{ … }
static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
const char *email UNUSED,
timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{ … }
static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid,
const char *email UNUSED,
timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{ … }
int read_ref_at(struct ref_store *refs, const char *refname,
unsigned int flags, timestamp_t at_time, int cnt,
struct object_id *oid, char **msg,
timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
{ … }
struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
struct strbuf *err)
{ … }
void ref_transaction_free(struct ref_transaction *transaction)
{ … }
struct ref_update *ref_transaction_add_update(
struct ref_transaction *transaction,
const char *refname, unsigned int flags,
const struct object_id *new_oid,
const struct object_id *old_oid,
const char *new_target, const char *old_target,
const char *msg)
{ … }
int ref_transaction_update(struct ref_transaction *transaction,
const char *refname,
const struct object_id *new_oid,
const struct object_id *old_oid,
const char *new_target,
const char *old_target,
unsigned int flags, const char *msg,
struct strbuf *err)
{ … }
int ref_transaction_create(struct ref_transaction *transaction,
const char *refname,
const struct object_id *new_oid,
const char *new_target,
unsigned int flags, const char *msg,
struct strbuf *err)
{ … }
int ref_transaction_delete(struct ref_transaction *transaction,
const char *refname,
const struct object_id *old_oid,
const char *old_target,
unsigned int flags,
const char *msg,
struct strbuf *err)
{ … }
int ref_transaction_verify(struct ref_transaction *transaction,
const char *refname,
const struct object_id *old_oid,
const char *old_target,
unsigned int flags,
struct strbuf *err)
{ … }
int refs_update_ref(struct ref_store *refs, const char *msg,
const char *refname, const struct object_id *new_oid,
const struct object_id *old_oid, unsigned int flags,
enum action_on_err onerr)
{ … }
static const char *match_parse_rule(const char *refname, const char *rule,
size_t *len)
{ … }
char *refs_shorten_unambiguous_ref(struct ref_store *refs,
const char *refname, int strict)
{ … }
int parse_hide_refs_config(const char *var, const char *value, const char *section,
struct strvec *hide_refs)
{ … }
int ref_is_hidden(const char *refname, const char *refname_full,
const struct strvec *hide_refs)
{ … }
const char **hidden_refs_to_excludes(const struct strvec *hide_refs)
{ … }
const char **get_namespaced_exclude_patterns(const char **exclude_patterns,
const char *namespace,
struct strvec *out)
{ … }
const char *find_descendant_ref(const char *dirname,
const struct string_list *extras,
const struct string_list *skip)
{ … }
int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{ … }
struct ref_iterator *refs_ref_iterator_begin(
struct ref_store *refs,
const char *prefix,
const char **exclude_patterns,
int trim,
enum do_for_each_ref_flags flags)
{ … }
static int do_for_each_ref(struct ref_store *refs, const char *prefix,
const char **exclude_patterns,
each_ref_fn fn, int trim,
enum do_for_each_ref_flags flags, void *cb_data)
{ … }
int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{ … }
int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
each_ref_fn fn, void *cb_data)
{ … }
int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
const char **exclude_patterns,
each_ref_fn fn, void *cb_data)
{ … }
int refs_for_each_replace_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{ … }
int refs_for_each_namespaced_ref(struct ref_store *refs,
const char **exclude_patterns,
each_ref_fn fn, void *cb_data)
{ … }
int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{ … }
int refs_for_each_include_root_refs(struct ref_store *refs, each_ref_fn fn,
void *cb_data)
{ … }
static int qsort_strcmp(const void *va, const void *vb)
{ … }
static void find_longest_prefixes_1(struct string_list *out,
struct strbuf *prefix,
const char **patterns, size_t nr)
{ … }
static void find_longest_prefixes(struct string_list *out,
const char **patterns)
{ … }
int refs_for_each_fullref_in_prefixes(struct ref_store *ref_store,
const char *namespace,
const char **patterns,
const char **exclude_patterns,
each_ref_fn fn, void *cb_data)
{ … }
static int refs_read_special_head(struct ref_store *ref_store,
const char *refname, struct object_id *oid,
struct strbuf *referent, unsigned int *type,
int *failure_errno)
{ … }
int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
struct object_id *oid, struct strbuf *referent,
unsigned int *type, int *failure_errno)
{ … }
int refs_read_symbolic_ref(struct ref_store *ref_store, const char *refname,
struct strbuf *referent)
{ … }
const char *refs_resolve_ref_unsafe(struct ref_store *refs,
const char *refname,
int resolve_flags,
struct object_id *oid,
int *flags)
{ … }
int ref_store_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err)
{ … }
int ref_store_remove_on_disk(struct ref_store *refs, struct strbuf *err)
{ … }
int repo_resolve_gitlink_ref(struct repository *r,
const char *submodule, const char *refname,
struct object_id *oid)
{ … }
static struct ref_store *lookup_ref_store_map(struct strmap *map,
const char *name)
{ … }
static struct ref_store *ref_store_init(struct repository *repo,
enum ref_storage_format format,
const char *gitdir,
unsigned int flags)
{ … }
void ref_store_release(struct ref_store *ref_store)
{ … }
struct ref_store *get_main_ref_store(struct repository *r)
{ … }
static void register_ref_store_map(struct strmap *map,
const char *type,
struct ref_store *refs,
const char *name)
{ … }
struct ref_store *repo_get_submodule_ref_store(struct repository *repo,
const char *submodule)
{ … }
struct ref_store *get_worktree_ref_store(const struct worktree *wt)
{ … }
void base_ref_store_init(struct ref_store *refs, struct repository *repo,
const char *path, const struct ref_storage_be *be)
{ … }
int refs_pack_refs(struct ref_store *refs, struct pack_refs_opts *opts)
{ … }
int peel_iterated_oid(struct repository *r, const struct object_id *base, struct object_id *peeled)
{ … }
int refs_update_symref(struct ref_store *refs, const char *ref,
const char *target, const char *logmsg)
{ … }
int ref_update_reject_duplicates(struct string_list *refnames,
struct strbuf *err)
{ … }
static int run_transaction_hook(struct ref_transaction *transaction,
const char *state)
{ … }
int ref_transaction_prepare(struct ref_transaction *transaction,
struct strbuf *err)
{ … }
int ref_transaction_abort(struct ref_transaction *transaction,
struct strbuf *err)
{ … }
int ref_transaction_commit(struct ref_transaction *transaction,
struct strbuf *err)
{ … }
int refs_verify_refname_available(struct ref_store *refs,
const char *refname,
const struct string_list *extras,
const struct string_list *skip,
struct strbuf *err)
{ … }
struct do_for_each_reflog_help { … };
static int do_for_each_reflog_helper(const char *refname,
const char *referent UNUSED,
const struct object_id *oid UNUSED,
int flags UNUSED,
void *cb_data)
{ … }
int refs_for_each_reflog(struct ref_store *refs, each_reflog_fn fn, void *cb_data)
{ … }
int refs_for_each_reflog_ent_reverse(struct ref_store *refs,
const char *refname,
each_reflog_ent_fn fn,
void *cb_data)
{ … }
int refs_for_each_reflog_ent(struct ref_store *refs, const char *refname,
each_reflog_ent_fn fn, void *cb_data)
{ … }
int refs_reflog_exists(struct ref_store *refs, const char *refname)
{ … }
int refs_create_reflog(struct ref_store *refs, const char *refname,
struct strbuf *err)
{ … }
int refs_delete_reflog(struct ref_store *refs, const char *refname)
{ … }
int refs_reflog_expire(struct ref_store *refs,
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)
{ … }
int initial_ref_transaction_commit(struct ref_transaction *transaction,
struct strbuf *err)
{ … }
void ref_transaction_for_each_queued_update(struct ref_transaction *transaction,
ref_transaction_for_each_queued_update_fn cb,
void *cb_data)
{ … }
int refs_delete_refs(struct ref_store *refs, const char *logmsg,
struct string_list *refnames, unsigned int flags)
{ … }
int refs_rename_ref(struct ref_store *refs, const char *oldref,
const char *newref, const char *logmsg)
{ … }
int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
const char *newref, const char *logmsg)
{ … }
const char *ref_update_original_update_refname(struct ref_update *update)
{ … }
int ref_update_has_null_new_value(struct ref_update *update)
{ … }
int ref_update_check_old_target(const char *referent, struct ref_update *update,
struct strbuf *err)
{ … }
struct migration_data { … };
static int migrate_one_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
int flags, void *cb_data)
{ … }
static int move_files(const char *from_path, const char *to_path, struct strbuf *errbuf)
{ … }
static int count_reflogs(const char *reflog UNUSED, void *payload)
{ … }
static int has_worktrees(void)
{ … }
int repo_migrate_ref_storage_format(struct repository *repo,
enum ref_storage_format format,
unsigned int flags,
struct strbuf *errbuf)
{ … }
int ref_update_expects_existing_old_ref(struct ref_update *update)
{ … }