refs: set up ref consistency check infrastructure

The "struct ref_store" is the base class which contains the "be" pointer
which provides backend-specific functions whose interfaces are defined
in the "ref_storage_be". We could reuse this polymorphism to define only
one interface. For every backend, we need to provide its own function
pointer.

The interfaces defined in the `ref_storage_be` are carefully structured
in semantic. It's organized as the five parts:

1. The name and the initialization interfaces.
2. The ref transaction interfaces.
3. The ref internal interfaces (pack, rename and copy).
4. The ref filesystem interfaces.
5. The reflog related interfaces.

To keep consistent with the git-fsck(1), add a new interface named
"fsck_refs_fn" to the end of "ref_storage_be". This semantic cannot be
grouped into any above five categories. Explicitly add blank line to
make it different from others.

Last, implement placeholder functions for each ref backends.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
shejialuo
2024-08-08 19:27:17 +08:00
committed by Junio C Hamano
parent 2de307cdb2
commit ab6f79d8df
7 changed files with 58 additions and 1 deletions

View File

@ -2303,6 +2303,12 @@ done:
return ret;
}
static int reftable_be_fsck(struct ref_store *ref_store,
struct fsck_options *o)
{
return 0;
}
struct ref_storage_be refs_be_reftable = {
.name = "reftable",
.init = reftable_be_init,
@ -2330,4 +2336,6 @@ struct ref_storage_be refs_be_reftable = {
.create_reflog = reftable_be_create_reflog,
.delete_reflog = reftable_be_delete_reflog,
.reflog_expire = reftable_be_reflog_expire,
.fsck = reftable_be_fsck,
};