refs: convert ref storage format to an enum
The ref storage format is tracked as a simple unsigned integer, which makes it harder than necessary to discover what that integer actually is or where its values are defined. Convert the ref storage format to instead be an enum. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
a83f7f51e1
commit
318efb966b
7
refs.c
7
refs.c
@ -37,14 +37,15 @@ static const struct ref_storage_be *refs_backends[] = {
|
||||
[REF_STORAGE_FORMAT_REFTABLE] = &refs_be_reftable,
|
||||
};
|
||||
|
||||
static const struct ref_storage_be *find_ref_storage_backend(unsigned int ref_storage_format)
|
||||
static const struct ref_storage_be *find_ref_storage_backend(
|
||||
enum ref_storage_format ref_storage_format)
|
||||
{
|
||||
if (ref_storage_format < ARRAY_SIZE(refs_backends))
|
||||
return refs_backends[ref_storage_format];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int ref_storage_format_by_name(const char *name)
|
||||
enum ref_storage_format ref_storage_format_by_name(const char *name)
|
||||
{
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(refs_backends); i++)
|
||||
if (refs_backends[i] && !strcmp(refs_backends[i]->name, name))
|
||||
@ -52,7 +53,7 @@ unsigned int ref_storage_format_by_name(const char *name)
|
||||
return REF_STORAGE_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
const char *ref_storage_format_to_name(unsigned int ref_storage_format)
|
||||
const char *ref_storage_format_to_name(enum ref_storage_format ref_storage_format)
|
||||
{
|
||||
const struct ref_storage_be *be = find_ref_storage_backend(ref_storage_format);
|
||||
if (!be)
|
||||
|
||||
Reference in New Issue
Block a user