refs: reorder some function definitions
This avoids the need to add forward declarations in the next step. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
3b9e3c2ced
commit
620a66b9e2
64
refs.c
64
refs.c
|
@ -1358,27 +1358,19 @@ static struct ref_store *main_ref_store;
|
||||||
/* A linked list of ref_stores for submodules: */
|
/* A linked list of ref_stores for submodules: */
|
||||||
static struct ref_store *submodule_ref_stores;
|
static struct ref_store *submodule_ref_stores;
|
||||||
|
|
||||||
void base_ref_store_init(struct ref_store *refs,
|
struct ref_store *lookup_ref_store(const char *submodule)
|
||||||
const struct ref_storage_be *be,
|
|
||||||
const char *submodule)
|
|
||||||
{
|
{
|
||||||
refs->be = be;
|
struct ref_store *refs;
|
||||||
if (!submodule) {
|
|
||||||
if (main_ref_store)
|
|
||||||
die("BUG: main_ref_store initialized twice");
|
|
||||||
|
|
||||||
refs->submodule = "";
|
if (!submodule || !*submodule)
|
||||||
refs->next = NULL;
|
return main_ref_store;
|
||||||
main_ref_store = refs;
|
|
||||||
} else {
|
|
||||||
if (lookup_ref_store(submodule))
|
|
||||||
die("BUG: ref_store for submodule '%s' initialized twice",
|
|
||||||
submodule);
|
|
||||||
|
|
||||||
refs->submodule = xstrdup(submodule);
|
for (refs = submodule_ref_stores; refs; refs = refs->next) {
|
||||||
refs->next = submodule_ref_stores;
|
if (!strcmp(submodule, refs->submodule))
|
||||||
submodule_ref_stores = refs;
|
return refs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ref_store *ref_store_init(const char *submodule)
|
struct ref_store *ref_store_init(const char *submodule)
|
||||||
|
@ -1395,21 +1387,6 @@ struct ref_store *ref_store_init(const char *submodule)
|
||||||
return be->init(submodule);
|
return be->init(submodule);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ref_store *lookup_ref_store(const char *submodule)
|
|
||||||
{
|
|
||||||
struct ref_store *refs;
|
|
||||||
|
|
||||||
if (!submodule || !*submodule)
|
|
||||||
return main_ref_store;
|
|
||||||
|
|
||||||
for (refs = submodule_ref_stores; refs; refs = refs->next) {
|
|
||||||
if (!strcmp(submodule, refs->submodule))
|
|
||||||
return refs;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ref_store *get_ref_store(const char *submodule)
|
struct ref_store *get_ref_store(const char *submodule)
|
||||||
{
|
{
|
||||||
struct ref_store *refs;
|
struct ref_store *refs;
|
||||||
|
@ -1435,6 +1412,29 @@ struct ref_store *get_ref_store(const char *submodule)
|
||||||
return refs;
|
return refs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void base_ref_store_init(struct ref_store *refs,
|
||||||
|
const struct ref_storage_be *be,
|
||||||
|
const char *submodule)
|
||||||
|
{
|
||||||
|
refs->be = be;
|
||||||
|
if (!submodule) {
|
||||||
|
if (main_ref_store)
|
||||||
|
die("BUG: main_ref_store initialized twice");
|
||||||
|
|
||||||
|
refs->submodule = "";
|
||||||
|
refs->next = NULL;
|
||||||
|
main_ref_store = refs;
|
||||||
|
} else {
|
||||||
|
if (lookup_ref_store(submodule))
|
||||||
|
die("BUG: ref_store for submodule '%s' initialized twice",
|
||||||
|
submodule);
|
||||||
|
|
||||||
|
refs->submodule = xstrdup(submodule);
|
||||||
|
refs->next = submodule_ref_stores;
|
||||||
|
submodule_ref_stores = refs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void assert_main_repository(struct ref_store *refs, const char *caller)
|
void assert_main_repository(struct ref_store *refs, const char *caller)
|
||||||
{
|
{
|
||||||
if (*refs->submodule)
|
if (*refs->submodule)
|
||||||
|
|
Loading…
Reference in New Issue