Skip to content

Commit c8f815c

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e5c475 commit c8f815c

File tree

2 files changed

+209
-268
lines changed

2 files changed

+209
-268
lines changed

refs.c

Lines changed: 0 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,6 @@ char *refs_resolve_refdup(struct ref_store *refs,
384384
return xstrdup_or_null(result);
385385
}
386386

387-
char *resolve_refdup(const char *refname, int resolve_flags,
388-
struct object_id *oid, int *flags)
389-
{
390-
return refs_resolve_refdup(get_main_ref_store(the_repository),
391-
refname, resolve_flags,
392-
oid, flags);
393-
}
394-
395387
/* The argument to for_each_filter_refs */
396388
struct for_each_ref_filter {
397389
const char *pattern;
@@ -409,33 +401,17 @@ int refs_read_ref_full(struct ref_store *refs, const char *refname,
409401
return -1;
410402
}
411403

412-
int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags)
413-
{
414-
return refs_read_ref_full(get_main_ref_store(the_repository), refname,
415-
resolve_flags, oid, flags);
416-
}
417-
418404
int refs_read_ref(struct ref_store *refs, const char *refname, struct object_id *oid)
419405
{
420406
return refs_read_ref_full(refs, refname, RESOLVE_REF_READING, oid, NULL);
421407
}
422408

423-
int read_ref(const char *refname, struct object_id *oid)
424-
{
425-
return refs_read_ref(get_main_ref_store(the_repository), refname, oid);
426-
}
427-
428409
int refs_ref_exists(struct ref_store *refs, const char *refname)
429410
{
430411
return !!refs_resolve_ref_unsafe(refs, refname, RESOLVE_REF_READING,
431412
NULL, NULL);
432413
}
433414

434-
int ref_exists(const char *refname)
435-
{
436-
return refs_ref_exists(get_main_ref_store(the_repository), refname);
437-
}
438-
439415
static int for_each_filter_refs(const char *refname,
440416
const struct object_id *oid,
441417
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)
530506
return refs_for_each_ref_in(refs, "refs/tags/", fn, cb_data);
531507
}
532508

533-
int for_each_tag_ref(each_ref_fn fn, void *cb_data)
534-
{
535-
return refs_for_each_tag_ref(get_main_ref_store(the_repository), fn, cb_data);
536-
}
537-
538509
int refs_for_each_branch_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
539510
{
540511
return refs_for_each_ref_in(refs, "refs/heads/", fn, cb_data);
541512
}
542513

543-
int for_each_branch_ref(each_ref_fn fn, void *cb_data)
544-
{
545-
return refs_for_each_branch_ref(get_main_ref_store(the_repository), fn, cb_data);
546-
}
547-
548514
int refs_for_each_remote_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
549515
{
550516
return refs_for_each_ref_in(refs, "refs/remotes/", fn, cb_data);
551517
}
552518

553-
int for_each_remote_ref(each_ref_fn fn, void *cb_data)
554-
{
555-
return refs_for_each_remote_ref(get_main_ref_store(the_repository), fn, cb_data);
556-
}
557-
558519
int refs_head_ref_namespaced(struct ref_store *refs, each_ref_fn fn, void *cb_data)
559520
{
560521
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
570531
return ret;
571532
}
572533

573-
int head_ref_namespaced(each_ref_fn fn, void *cb_data)
574-
{
575-
return refs_head_ref_namespaced(get_main_ref_store(the_repository),
576-
fn, cb_data);
577-
}
578-
579534
void normalize_glob_ref(struct string_list_item *item, const char *prefix,
580535
const char *pattern)
581536
{
@@ -632,25 +587,12 @@ int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn,
632587
return ret;
633588
}
634589

635-
int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
636-
const char *prefix, void *cb_data)
637-
{
638-
return refs_for_each_glob_ref_in(get_main_ref_store(the_repository),
639-
fn, pattern, prefix, cb_data);
640-
}
641-
642590
int refs_for_each_glob_ref(struct ref_store *refs, each_ref_fn fn,
643591
const char *pattern, void *cb_data)
644592
{
645593
return refs_for_each_glob_ref_in(refs, fn, pattern, NULL, cb_data);
646594
}
647595

648-
int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
649-
{
650-
return refs_for_each_glob_ref(get_main_ref_store(the_repository),
651-
fn, pattern, cb_data);
652-
}
653-
654596
const char *prettify_refname(const char *name)
655597
{
656598
if (skip_prefix(name, "refs/heads/", &name) ||
@@ -1024,13 +966,6 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
1024966
return 0;
1025967
}
1026968

1027-
int delete_ref(const char *msg, const char *refname,
1028-
const struct object_id *old_oid, unsigned int flags)
1029-
{
1030-
return refs_delete_ref(get_main_ref_store(the_repository), msg, refname,
1031-
old_oid, flags);
1032-
}
1033-
1034969
static void copy_reflog_msg(struct strbuf *sb, const char *msg)
1035970
{
1036971
char c;
@@ -1223,11 +1158,6 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
12231158
return tr;
12241159
}
12251160

1226-
struct ref_transaction *ref_transaction_begin(struct strbuf *err)
1227-
{
1228-
return ref_store_transaction_begin(get_main_ref_store(the_repository), err);
1229-
}
1230-
12311161
void ref_transaction_free(struct ref_transaction *transaction)
12321162
{
12331163
size_t i;
@@ -1396,15 +1326,6 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
13961326
return 0;
13971327
}
13981328

1399-
int update_ref(const char *msg, const char *refname,
1400-
const struct object_id *new_oid,
1401-
const struct object_id *old_oid,
1402-
unsigned int flags, enum action_on_err onerr)
1403-
{
1404-
return refs_update_ref(get_main_ref_store(the_repository), msg, refname, new_oid,
1405-
old_oid, flags, onerr);
1406-
}
1407-
14081329
/*
14091330
* Check that the string refname matches a rule of the form
14101331
* "{prefix}%.*s{suffix}". So "foo/bar/baz" would match the rule
@@ -1506,12 +1427,6 @@ char *refs_shorten_unambiguous_ref(struct ref_store *refs,
15061427
return xstrdup(refname);
15071428
}
15081429

1509-
char *shorten_unambiguous_ref(const char *refname, int strict)
1510-
{
1511-
return refs_shorten_unambiguous_ref(get_main_ref_store(the_repository),
1512-
refname, strict);
1513-
}
1514-
15151430
int parse_hide_refs_config(const char *var, const char *value, const char *section,
15161431
struct strvec *hide_refs)
15171432
{
@@ -1630,11 +1545,6 @@ int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
16301545
return 0;
16311546
}
16321547

1633-
int head_ref(each_ref_fn fn, void *cb_data)
1634-
{
1635-
return refs_head_ref(get_main_ref_store(the_repository), fn, cb_data);
1636-
}
1637-
16381548
struct ref_iterator *refs_ref_iterator_begin(
16391549
struct ref_store *refs,
16401550
const char *prefix,
@@ -1729,30 +1639,12 @@ int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
17291639
return do_for_each_ref(refs, "", NULL, fn, 0, 0, cb_data);
17301640
}
17311641

1732-
int for_each_ref(each_ref_fn fn, void *cb_data)
1733-
{
1734-
return refs_for_each_ref(get_main_ref_store(the_repository), fn, cb_data);
1735-
}
1736-
17371642
int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
17381643
each_ref_fn fn, void *cb_data)
17391644
{
17401645
return do_for_each_ref(refs, prefix, NULL, fn, strlen(prefix), 0, cb_data);
17411646
}
17421647

1743-
int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
1744-
{
1745-
return refs_for_each_ref_in(get_main_ref_store(the_repository), prefix, fn, cb_data);
1746-
}
1747-
1748-
int for_each_fullref_in(const char *prefix,
1749-
const char **exclude_patterns,
1750-
each_ref_fn fn, void *cb_data)
1751-
{
1752-
return refs_for_each_fullref_in(get_main_ref_store(the_repository),
1753-
prefix, exclude_patterns, fn, cb_data);
1754-
}
1755-
17561648
int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
17571649
const char **exclude_patterns,
17581650
each_ref_fn fn, void *cb_data)
@@ -1780,24 +1672,12 @@ int refs_for_each_namespaced_ref(struct ref_store *refs,
17801672
return ret;
17811673
}
17821674

1783-
int for_each_namespaced_ref(const char **exclude_patterns,
1784-
each_ref_fn fn, void *cb_data)
1785-
{
1786-
return refs_for_each_namespaced_ref(get_main_ref_store(the_repository),
1787-
exclude_patterns, fn, cb_data);
1788-
}
1789-
17901675
int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
17911676
{
17921677
return do_for_each_ref(refs, "", NULL, fn, 0,
17931678
DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
17941679
}
17951680

1796-
int for_each_rawref(each_ref_fn fn, void *cb_data)
1797-
{
1798-
return refs_for_each_rawref(get_main_ref_store(the_repository), fn, cb_data);
1799-
}
1800-
18011681
int refs_for_each_include_root_refs(struct ref_store *refs, each_ref_fn fn,
18021682
void *cb_data)
18031683
{
@@ -2063,13 +1943,6 @@ int refs_init_db(struct ref_store *refs, int flags, struct strbuf *err)
20631943
return refs->be->init_db(refs, flags, err);
20641944
}
20651945

2066-
const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
2067-
struct object_id *oid, int *flags)
2068-
{
2069-
return refs_resolve_ref_unsafe(get_main_ref_store(the_repository), refname,
2070-
resolve_flags, oid, flags);
2071-
}
2072-
20731946
int resolve_gitlink_ref(const char *submodule, const char *refname,
20741947
struct object_id *oid)
20751948
{
@@ -2323,13 +2196,6 @@ int refs_create_symref(struct ref_store *refs,
23232196
return retval;
23242197
}
23252198

2326-
int create_symref(const char *ref_target, const char *refs_heads_master,
2327-
const char *logmsg)
2328-
{
2329-
return refs_create_symref(get_main_ref_store(the_repository), ref_target,
2330-
refs_heads_master, logmsg);
2331-
}
2332-
23332199
int ref_update_reject_duplicates(struct string_list *refnames,
23342200
struct strbuf *err)
23352201
{
@@ -2623,11 +2489,6 @@ int refs_for_each_reflog(struct ref_store *refs, each_reflog_fn fn, void *cb_dat
26232489
do_for_each_reflog_helper, &hp);
26242490
}
26252491

2626-
int for_each_reflog(each_reflog_fn fn, void *cb_data)
2627-
{
2628-
return refs_for_each_reflog(get_main_ref_store(the_repository), fn, cb_data);
2629-
}
2630-
26312492
int refs_for_each_reflog_ent_reverse(struct ref_store *refs,
26322493
const char *refname,
26332494
each_reflog_ent_fn fn,
@@ -2637,58 +2498,28 @@ int refs_for_each_reflog_ent_reverse(struct ref_store *refs,
26372498
fn, cb_data);
26382499
}
26392500

2640-
int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn,
2641-
void *cb_data)
2642-
{
2643-
return refs_for_each_reflog_ent_reverse(get_main_ref_store(the_repository),
2644-
refname, fn, cb_data);
2645-
}
2646-
26472501
int refs_for_each_reflog_ent(struct ref_store *refs, const char *refname,
26482502
each_reflog_ent_fn fn, void *cb_data)
26492503
{
26502504
return refs->be->for_each_reflog_ent(refs, refname, fn, cb_data);
26512505
}
26522506

2653-
int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn,
2654-
void *cb_data)
2655-
{
2656-
return refs_for_each_reflog_ent(get_main_ref_store(the_repository), refname,
2657-
fn, cb_data);
2658-
}
2659-
26602507
int refs_reflog_exists(struct ref_store *refs, const char *refname)
26612508
{
26622509
return refs->be->reflog_exists(refs, refname);
26632510
}
26642511

2665-
int reflog_exists(const char *refname)
2666-
{
2667-
return refs_reflog_exists(get_main_ref_store(the_repository), refname);
2668-
}
2669-
26702512
int refs_create_reflog(struct ref_store *refs, const char *refname,
26712513
struct strbuf *err)
26722514
{
26732515
return refs->be->create_reflog(refs, refname, err);
26742516
}
26752517

2676-
int safe_create_reflog(const char *refname, struct strbuf *err)
2677-
{
2678-
return refs_create_reflog(get_main_ref_store(the_repository), refname,
2679-
err);
2680-
}
2681-
26822518
int refs_delete_reflog(struct ref_store *refs, const char *refname)
26832519
{
26842520
return refs->be->delete_reflog(refs, refname);
26852521
}
26862522

2687-
int delete_reflog(const char *refname)
2688-
{
2689-
return refs_delete_reflog(get_main_ref_store(the_repository), refname);
2690-
}
2691-
26922523
int refs_reflog_expire(struct ref_store *refs,
26932524
const char *refname,
26942525
unsigned int flags,
@@ -2702,19 +2533,6 @@ int refs_reflog_expire(struct ref_store *refs,
27022533
cleanup_fn, policy_cb_data);
27032534
}
27042535

2705-
int reflog_expire(const char *refname,
2706-
unsigned int flags,
2707-
reflog_expiry_prepare_fn prepare_fn,
2708-
reflog_expiry_should_prune_fn should_prune_fn,
2709-
reflog_expiry_cleanup_fn cleanup_fn,
2710-
void *policy_cb_data)
2711-
{
2712-
return refs_reflog_expire(get_main_ref_store(the_repository),
2713-
refname, flags,
2714-
prepare_fn, should_prune_fn,
2715-
cleanup_fn, policy_cb_data);
2716-
}
2717-
27182536
int initial_ref_transaction_commit(struct ref_transaction *transaction,
27192537
struct strbuf *err)
27202538
{
@@ -2793,12 +2611,6 @@ int refs_delete_refs(struct ref_store *refs, const char *logmsg,
27932611
return ret;
27942612
}
27952613

2796-
int delete_refs(const char *msg, struct string_list *refnames,
2797-
unsigned int flags)
2798-
{
2799-
return refs_delete_refs(get_main_ref_store(the_repository), msg, refnames, flags);
2800-
}
2801-
28022614
int refs_rename_ref(struct ref_store *refs, const char *oldref,
28032615
const char *newref, const char *logmsg)
28042616
{
@@ -2811,11 +2623,6 @@ int refs_rename_ref(struct ref_store *refs, const char *oldref,
28112623
return retval;
28122624
}
28132625

2814-
int rename_ref(const char *oldref, const char *newref, const char *logmsg)
2815-
{
2816-
return refs_rename_ref(get_main_ref_store(the_repository), oldref, newref, logmsg);
2817-
}
2818-
28192626
int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
28202627
const char *newref, const char *logmsg)
28212628
{
@@ -2827,8 +2634,3 @@ int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
28272634
free(msg);
28282635
return retval;
28292636
}
2830-
2831-
int copy_existing_ref(const char *oldref, const char *newref, const char *logmsg)
2832-
{
2833-
return refs_copy_existing_ref(get_main_ref_store(the_repository), oldref, newref, logmsg);
2834-
}

0 commit comments

Comments
 (0)