From 3dce444f178503bf3da13ade6f79c80d6964d175 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 4 Sep 2016 18:08:10 +0200 Subject: refs: add a backend method structure Add a `struct ref_storage_be` to represent types of reference stores. In OO notation, this is the class, and will soon hold some class methods (e.g., a factory to create new ref_store instances) and will also serve as the vtable for ref_store instances of that type. As yet, the backends cannot do anything. Signed-off-by: Ronnie Sahlberg Signed-off-by: David Turner Signed-off-by: Junio C Hamano Signed-off-by: Jeff King Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- refs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'refs.c') diff --git a/refs.c b/refs.c index 256fef5da0..bee9a4571e 100644 --- a/refs.c +++ b/refs.c @@ -9,6 +9,25 @@ #include "object.h" #include "tag.h" +/* + * List of all available backends + */ +static struct ref_storage_be *refs_backends = &refs_be_files; + +static struct ref_storage_be *find_ref_storage_backend(const char *name) +{ + struct ref_storage_be *be; + for (be = refs_backends; be; be = be->next) + if (!strcmp(be->name, name)) + return be; + return NULL; +} + +int ref_storage_backend_exists(const char *name) +{ + return find_ref_storage_backend(name) != NULL; +} + /* * How to handle various characters in refnames: * 0: An acceptable character for refs -- cgit v1.2.1