packed-backend: remove stub BUG(...) functions

Remove the stub BUG(...) functions previously used by the "struct ref_storage_be refs_be_packed" backend. We never call any functions in the packed backend by using it as a "normal" primary ref store, instead we'll always initialize a "files" backend ref-store. It will then via the "packed_ref_store" member of "struct files_ref_store" call selected functions in the "packed" backend, and we'll in addition call others via wrappers in refs.c. So while these would arguably give us *slightly* more meaningful error messages we'll NULL the missing members in the initializer anyway, so we'll reliably get a segfault if we're ever changing the backend and having it call something it doesn't have. So there's no need for this verbose boilerplate, and as shown in a subsequent commit it might even lead to some confusion about the packed backend being a "real" backend. Let's make it clear that it's not. As an aside, this also fixes a warning emitted by SunCC in at least versions 12.5 and 12.6 of Oracle Developer Studio: "refs/packed-backend.c", line 1599: warning: Function has no return statement : packed_create_symref "refs/packed-backend.c", line 1606: warning: Function has no return statement : packed_rename_ref) "refs/packed-backend.c", line 1613: warning: Function has no return statement : packed_copy_ref "refs/packed-backend.c", line 1648: warning: Function has no return statement : packed_create_reflog Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 17, 2022 at 18:27 UTC ca40893a41e2cc742316232f3d044df99a4cdac2
1 file changed +9 -79
refs/packed-backend.c
+9 -79
@@ -1591,81 +1591,11 @@ static int packed_pack_refs(struct ref_store *ref_store, unsigned int flags)
1591 return 0;
1592 }
1593
1594 -static int packed_create_symref(struct ref_store *ref_store,
1595 - const char *refname, const char *target,
1596 - const char *logmsg)
1597 -{
1598 - BUG("packed reference store does not support symrefs");
1599 -}
1600 -
1601 -static int packed_rename_ref(struct ref_store *ref_store,
1602 - const char *oldrefname, const char *newrefname,
1603 - const char *logmsg)
1604 -{
1605 - BUG("packed reference store does not support renaming references");
1606 -}
1607 -
1608 -static int packed_copy_ref(struct ref_store *ref_store,
1609 - const char *oldrefname, const char *newrefname,
1610 - const char *logmsg)
1611 -{
1612 - BUG("packed reference store does not support copying references");
1613 -}
1614 -
1594 static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_store)
1595 {
1596 return empty_ref_iterator_begin();
1597 }
1598
1620 -static int packed_for_each_reflog_ent(struct ref_store *ref_store,
1621 - const char *refname,
1622 - each_reflog_ent_fn fn, void *cb_data)
1623 -{
1624 - BUG("packed reference store does not support reflogs");
1625 - return 0;
1626 -}
1627 -
1628 -static int packed_for_each_reflog_ent_reverse(struct ref_store *ref_store,
1629 - const char *refname,
1630 - each_reflog_ent_fn fn,
1631 - void *cb_data)
1632 -{
1633 - BUG("packed reference store does not support reflogs");
1634 - return 0;
1635 -}
1636 -
1637 -static int packed_reflog_exists(struct ref_store *ref_store,
1638 - const char *refname)
1639 -{
1640 - BUG("packed reference store does not support reflogs");
1641 - return 0;
1642 -}
1643 -
1644 -static int packed_create_reflog(struct ref_store *ref_store,
1645 - const char *refname, struct strbuf *err)
1646 -{
1647 - BUG("packed reference store does not support reflogs");
1648 -}
1649 -
1650 -static int packed_delete_reflog(struct ref_store *ref_store,
1651 - const char *refname)
1652 -{
1653 - BUG("packed reference store does not support reflogs");
1654 - return 0;
1655 -}
1656 -
1657 -static int packed_reflog_expire(struct ref_store *ref_store,
1658 - const char *refname,
1659 - unsigned int flags,
1660 - reflog_expiry_prepare_fn prepare_fn,
1661 - reflog_expiry_should_prune_fn should_prune_fn,
1662 - reflog_expiry_cleanup_fn cleanup_fn,
1663 - void *policy_cb_data)
1664 -{
1665 - BUG("packed reference store does not support reflogs");
1666 - return 0;
1667 -}
1668 -
1599 struct ref_storage_be refs_be_packed = {
1600 .next = NULL,
1601 .name = "packed",
@@ -1677,20 +1607,20 @@ struct ref_storage_be refs_be_packed = {
1607 .initial_transaction_commit = packed_initial_transaction_commit,
1608
1609 .pack_refs = packed_pack_refs,
1680 - .create_symref = packed_create_symref,
1610 + .create_symref = NULL,
1611 .delete_refs = packed_delete_refs,
1682 - .rename_ref = packed_rename_ref,
1683 - .copy_ref = packed_copy_ref,
1612 + .rename_ref = NULL,
1613 + .copy_ref = NULL,
1614
1615 .iterator_begin = packed_ref_iterator_begin,
1616 .read_raw_ref = packed_read_raw_ref,
1617 .read_symbolic_ref = NULL,
1618
1619 .reflog_iterator_begin = packed_reflog_iterator_begin,
1690 - .for_each_reflog_ent = packed_for_each_reflog_ent,
1691 - .for_each_reflog_ent_reverse = packed_for_each_reflog_ent_reverse,
1692 - .reflog_exists = packed_reflog_exists,
1693 - .create_reflog = packed_create_reflog,
1694 - .delete_reflog = packed_delete_reflog,
1695 - .reflog_expire = packed_reflog_expire
1620 + .for_each_reflog_ent = NULL,
1621 + .for_each_reflog_ent_reverse = NULL,
1622 + .reflog_exists = NULL,
1623 + .create_reflog = NULL,
1624 + .delete_reflog = NULL,
1625 + .reflog_expire = NULL,
1626 };