Skip to content

Commit ca40893

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5010364 commit ca40893

File tree

1 file changed

+9
-79
lines changed

1 file changed

+9
-79
lines changed

refs/packed-backend.c

Lines changed: 9 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,81 +1591,11 @@ static int packed_pack_refs(struct ref_store *ref_store, unsigned int flags)
15911591
return 0;
15921592
}
15931593

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-
16151594
static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_store)
16161595
{
16171596
return empty_ref_iterator_begin();
16181597
}
16191598

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-
16691599
struct ref_storage_be refs_be_packed = {
16701600
.next = NULL,
16711601
.name = "packed",
@@ -1677,20 +1607,20 @@ struct ref_storage_be refs_be_packed = {
16771607
.initial_transaction_commit = packed_initial_transaction_commit,
16781608

16791609
.pack_refs = packed_pack_refs,
1680-
.create_symref = packed_create_symref,
1610+
.create_symref = NULL,
16811611
.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,
16841614

16851615
.iterator_begin = packed_ref_iterator_begin,
16861616
.read_raw_ref = packed_read_raw_ref,
16871617
.read_symbolic_ref = NULL,
16881618

16891619
.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,
16961626
};

0 commit comments

Comments
 (0)