Show 48 quoted lines
> On 09/29/2015 12:02 AM, David Turner wrote:
> > The file backend doesn't need this function, but other backends might.
> >
> > Signed-off-by: David Turner <dturner@twopensource.com>
> > Signed-off-by: Ronnie Sahlberg <rsahlberg@google.com>
> > ---
> > refs-be-files.c | 1 +
> > refs.c | 4 +++-
> > refs.h | 4 +++-
> > 3 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/refs-be-files.c b/refs-be-files.c
> > index 37e244a..eaa74b6 100644
> > --- a/refs-be-files.c
> > +++ b/refs-be-files.c
> > @@ -3737,6 +3737,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
> > struct ref_be refs_be_files = {
> > NULL,
> > "files",
> > + NULL,
> > files_transaction_begin,
> > files_transaction_update,
> > files_transaction_create,
> > diff --git a/refs.c b/refs.c
> > index 769574d..9ce10b7 100644
> > --- a/refs.c
> > +++ b/refs.c
> > @@ -19,13 +19,15 @@ struct ref_be *refs_backends = &refs_be_files;
> > /*
> > * This function is used to switch to an alternate backend.
> > */
> > -int set_refs_backend(const char *name)
> > +int set_refs_backend(const char *name, void *init_data)
> > {
> > struct ref_be *be;
> >
> > for (be = refs_backends; be; be = be->next)
> > if (!strcmp(be->name, name)) {
> > the_refs_backend = be;
> > + if (be->init_backend)
> > + be->init_backend(init_data);
>
> I don't like that this virtual function, alone among all of them
> introduced so far, is allowed to be NULL. That seems non-obvious and
> something extra that devs have to remember.
>
> I think it would be better for the files backend to define a do-nothing
> function that can be stuck in this slot.