refs: remove functions without ref store

The preceding commit has rewritten all callers of ref-related functions
to use the equivalents that accept a `struct ref_store`. Consequently,
the respective variants without the ref store are now unused. Remove
them.

There are likely patch series in-flight that use the now-removed
functions. To help the authors, the old implementations have been added
to "refs.c" in an ifdef'd section as a reference for how to migrate each
of the respective callers.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-05-07 09:11:58 +02:00
committed by Junio C Hamano
parent 2e5c4758b7
commit c8f815c208
2 changed files with 209 additions and 268 deletions

198
refs.c
View File

@ -384,14 +384,6 @@ char *refs_resolve_refdup(struct ref_store *refs,
return xstrdup_or_null(result);
}
char *resolve_refdup(const char *refname, int resolve_flags,
struct object_id *oid, int *flags)
{
return refs_resolve_refdup(get_main_ref_store(the_repository),
refname, resolve_flags,
oid, flags);
}
/* The argument to for_each_filter_refs */
struct for_each_ref_filter {
const char *pattern;
@ -409,33 +401,17 @@ int refs_read_ref_full(struct ref_store *refs, const char *refname,
return -1;
}
int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags)
{
return refs_read_ref_full(get_main_ref_store(the_repository), refname,
resolve_flags, oid, flags);
}
int refs_read_ref(struct ref_store *refs, const char *refname, struct object_id *oid)
{
return refs_read_ref_full(refs, refname, RESOLVE_REF_READING, oid, NULL);
}
int read_ref(const char *refname, struct object_id *oid)
{
return refs_read_ref(get_main_ref_store(the_repository), refname, oid);
}
int refs_ref_exists(struct ref_store *refs, const char *refname)
{
return !!refs_resolve_ref_unsafe(refs, refname, RESOLVE_REF_READING,
NULL, NULL);
}
int ref_exists(const char *refname)
{
return refs_ref_exists(get_main_ref_store(the_repository), refname);
}
static int for_each_filter_refs(const char *refname,
const struct object_id *oid,
int flags, void *data)
@ -530,31 +506,16 @@ int refs_for_each_tag_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
return refs_for_each_ref_in(refs, "refs/tags/", fn, cb_data);
}
int for_each_tag_ref(each_ref_fn fn, void *cb_data)
{
return refs_for_each_tag_ref(get_main_ref_store(the_repository), fn, cb_data);
}
int refs_for_each_branch_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{
return refs_for_each_ref_in(refs, "refs/heads/", fn, cb_data);
}
int for_each_branch_ref(each_ref_fn fn, void *cb_data)
{
return refs_for_each_branch_ref(get_main_ref_store(the_repository), fn, cb_data);
}
int refs_for_each_remote_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{
return refs_for_each_ref_in(refs, "refs/remotes/", fn, cb_data);
}
int for_each_remote_ref(each_ref_fn fn, void *cb_data)
{
return refs_for_each_remote_ref(get_main_ref_store(the_repository), fn, cb_data);
}
int refs_head_ref_namespaced(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{
struct strbuf buf = STRBUF_INIT;
@ -570,12 +531,6 @@ int refs_head_ref_namespaced(struct ref_store *refs, each_ref_fn fn, void *cb_da
return ret;
}
int head_ref_namespaced(each_ref_fn fn, void *cb_data)
{
return refs_head_ref_namespaced(get_main_ref_store(the_repository),
fn, cb_data);
}
void normalize_glob_ref(struct string_list_item *item, const char *prefix,
const char *pattern)
{
@ -632,25 +587,12 @@ int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn,
return ret;
}
int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
const char *prefix, void *cb_data)
{
return refs_for_each_glob_ref_in(get_main_ref_store(the_repository),
fn, pattern, prefix, cb_data);
}
int refs_for_each_glob_ref(struct ref_store *refs, each_ref_fn fn,
const char *pattern, void *cb_data)
{
return refs_for_each_glob_ref_in(refs, fn, pattern, NULL, cb_data);
}
int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
{
return refs_for_each_glob_ref(get_main_ref_store(the_repository),
fn, pattern, cb_data);
}
const char *prettify_refname(const char *name)
{
if (skip_prefix(name, "refs/heads/", &name) ||
@ -1024,13 +966,6 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
return 0;
}
int delete_ref(const char *msg, const char *refname,
const struct object_id *old_oid, unsigned int flags)
{
return refs_delete_ref(get_main_ref_store(the_repository), msg, refname,
old_oid, flags);
}
static void copy_reflog_msg(struct strbuf *sb, const char *msg)
{
char c;
@ -1223,11 +1158,6 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
return tr;
}
struct ref_transaction *ref_transaction_begin(struct strbuf *err)
{
return ref_store_transaction_begin(get_main_ref_store(the_repository), err);
}
void ref_transaction_free(struct ref_transaction *transaction)
{
size_t i;
@ -1396,15 +1326,6 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
return 0;
}
int update_ref(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)
{
return refs_update_ref(get_main_ref_store(the_repository), msg, refname, new_oid,
old_oid, flags, onerr);
}
/*
* Check that the string refname matches a rule of the form
* "{prefix}%.*s{suffix}". So "foo/bar/baz" would match the rule
@ -1506,12 +1427,6 @@ char *refs_shorten_unambiguous_ref(struct ref_store *refs,
return xstrdup(refname);
}
char *shorten_unambiguous_ref(const char *refname, int strict)
{
return refs_shorten_unambiguous_ref(get_main_ref_store(the_repository),
refname, strict);
}
int parse_hide_refs_config(const char *var, const char *value, const char *section,
struct strvec *hide_refs)
{
@ -1630,11 +1545,6 @@ int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
return 0;
}
int head_ref(each_ref_fn fn, void *cb_data)
{
return refs_head_ref(get_main_ref_store(the_repository), fn, cb_data);
}
struct ref_iterator *refs_ref_iterator_begin(
struct ref_store *refs,
const char *prefix,
@ -1729,30 +1639,12 @@ int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
return do_for_each_ref(refs, "", NULL, fn, 0, 0, cb_data);
}
int for_each_ref(each_ref_fn fn, void *cb_data)
{
return refs_for_each_ref(get_main_ref_store(the_repository), fn, cb_data);
}
int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
each_ref_fn fn, void *cb_data)
{
return do_for_each_ref(refs, prefix, NULL, fn, strlen(prefix), 0, cb_data);
}
int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
{
return refs_for_each_ref_in(get_main_ref_store(the_repository), prefix, fn, cb_data);
}
int for_each_fullref_in(const char *prefix,
const char **exclude_patterns,
each_ref_fn fn, void *cb_data)
{
return refs_for_each_fullref_in(get_main_ref_store(the_repository),
prefix, exclude_patterns, fn, 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)
@ -1780,24 +1672,12 @@ int refs_for_each_namespaced_ref(struct ref_store *refs,
return ret;
}
int for_each_namespaced_ref(const char **exclude_patterns,
each_ref_fn fn, void *cb_data)
{
return refs_for_each_namespaced_ref(get_main_ref_store(the_repository),
exclude_patterns, fn, cb_data);
}
int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{
return do_for_each_ref(refs, "", NULL, fn, 0,
DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
}
int for_each_rawref(each_ref_fn fn, void *cb_data)
{
return refs_for_each_rawref(get_main_ref_store(the_repository), fn, cb_data);
}
int refs_for_each_include_root_refs(struct ref_store *refs, each_ref_fn fn,
void *cb_data)
{
@ -2063,13 +1943,6 @@ int refs_init_db(struct ref_store *refs, int flags, struct strbuf *err)
return refs->be->init_db(refs, flags, err);
}
const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
struct object_id *oid, int *flags)
{
return refs_resolve_ref_unsafe(get_main_ref_store(the_repository), refname,
resolve_flags, oid, flags);
}
int resolve_gitlink_ref(const char *submodule, const char *refname,
struct object_id *oid)
{
@ -2323,13 +2196,6 @@ int refs_create_symref(struct ref_store *refs,
return retval;
}
int create_symref(const char *ref_target, const char *refs_heads_master,
const char *logmsg)
{
return refs_create_symref(get_main_ref_store(the_repository), ref_target,
refs_heads_master, logmsg);
}
int ref_update_reject_duplicates(struct string_list *refnames,
struct strbuf *err)
{
@ -2623,11 +2489,6 @@ int refs_for_each_reflog(struct ref_store *refs, each_reflog_fn fn, void *cb_dat
do_for_each_reflog_helper, &hp);
}
int for_each_reflog(each_reflog_fn fn, void *cb_data)
{
return refs_for_each_reflog(get_main_ref_store(the_repository), fn, cb_data);
}
int refs_for_each_reflog_ent_reverse(struct ref_store *refs,
const char *refname,
each_reflog_ent_fn fn,
@ -2637,58 +2498,28 @@ int refs_for_each_reflog_ent_reverse(struct ref_store *refs,
fn, cb_data);
}
int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn,
void *cb_data)
{
return refs_for_each_reflog_ent_reverse(get_main_ref_store(the_repository),
refname, fn, cb_data);
}
int refs_for_each_reflog_ent(struct ref_store *refs, const char *refname,
each_reflog_ent_fn fn, void *cb_data)
{
return refs->be->for_each_reflog_ent(refs, refname, fn, cb_data);
}
int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn,
void *cb_data)
{
return refs_for_each_reflog_ent(get_main_ref_store(the_repository), refname,
fn, cb_data);
}
int refs_reflog_exists(struct ref_store *refs, const char *refname)
{
return refs->be->reflog_exists(refs, refname);
}
int reflog_exists(const char *refname)
{
return refs_reflog_exists(get_main_ref_store(the_repository), refname);
}
int refs_create_reflog(struct ref_store *refs, const char *refname,
struct strbuf *err)
{
return refs->be->create_reflog(refs, refname, err);
}
int safe_create_reflog(const char *refname, struct strbuf *err)
{
return refs_create_reflog(get_main_ref_store(the_repository), refname,
err);
}
int refs_delete_reflog(struct ref_store *refs, const char *refname)
{
return refs->be->delete_reflog(refs, refname);
}
int delete_reflog(const char *refname)
{
return refs_delete_reflog(get_main_ref_store(the_repository), refname);
}
int refs_reflog_expire(struct ref_store *refs,
const char *refname,
unsigned int flags,
@ -2702,19 +2533,6 @@ int refs_reflog_expire(struct ref_store *refs,
cleanup_fn, policy_cb_data);
}
int reflog_expire(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)
{
return refs_reflog_expire(get_main_ref_store(the_repository),
refname, flags,
prepare_fn, should_prune_fn,
cleanup_fn, policy_cb_data);
}
int initial_ref_transaction_commit(struct ref_transaction *transaction,
struct strbuf *err)
{
@ -2793,12 +2611,6 @@ out:
return ret;
}
int delete_refs(const char *msg, struct string_list *refnames,
unsigned int flags)
{
return refs_delete_refs(get_main_ref_store(the_repository), msg, refnames, flags);
}
int refs_rename_ref(struct ref_store *refs, const char *oldref,
const char *newref, const char *logmsg)
{
@ -2811,11 +2623,6 @@ int refs_rename_ref(struct ref_store *refs, const char *oldref,
return retval;
}
int rename_ref(const char *oldref, const char *newref, const char *logmsg)
{
return refs_rename_ref(get_main_ref_store(the_repository), oldref, newref, logmsg);
}
int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
const char *newref, const char *logmsg)
{
@ -2827,8 +2634,3 @@ int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
free(msg);
return retval;
}
int copy_existing_ref(const char *oldref, const char *newref, const char *logmsg)
{
return refs_copy_existing_ref(get_main_ref_store(the_repository), oldref, newref, logmsg);
}