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>

Michael Haggerty committed Feb 10, 2017 at 12:16 UTC 620a66b9e2d68433aab2ae3daf5a62896c0547d8
1 file changed +32 -32
refs.c
+32 -32
@@ -1358,27 +1358,19 @@ static struct ref_store *main_ref_store;
1358 /* A linked list of ref_stores for submodules: */
1359 static struct ref_store *submodule_ref_stores;
1360
1361 -void base_ref_store_init(struct ref_store *refs,
1362 - const struct ref_storage_be *be,
1363 - const char *submodule)
1361 +struct ref_store *lookup_ref_store(const char *submodule)
1362 {
1365 - refs->be = be;
1366 - if (!submodule) {
1367 - if (main_ref_store)
1368 - die("BUG: main_ref_store initialized twice");
1363 + struct ref_store *refs;
1364
1370 - refs->submodule = "";
1371 - refs->next = NULL;
1372 - main_ref_store = refs;
1373 - } else {
1374 - if (lookup_ref_store(submodule))
1375 - die("BUG: ref_store for submodule '%s' initialized twice",
1376 - submodule);
1365 + if (!submodule || !*submodule)
1366 + return main_ref_store;
1367
1378 - refs->submodule = xstrdup(submodule);
1379 - refs->next = submodule_ref_stores;
1380 - submodule_ref_stores = refs;
1368 + for (refs = submodule_ref_stores; refs; refs = refs->next) {
1369 + if (!strcmp(submodule, refs->submodule))
1370 + return refs;
1371 }
1372 +
1373 + return NULL;
1374 }
1375
1376 struct ref_store *ref_store_init(const char *submodule)
@@ -1395,21 +1387,6 @@ struct ref_store *ref_store_init(const char *submodule)
1387 return be->init(submodule);
1388 }
1389
1398 -struct ref_store *lookup_ref_store(const char *submodule)
1399 -{
1400 - struct ref_store *refs;
1401 -
1402 - if (!submodule || !*submodule)
1403 - return main_ref_store;
1404 -
1405 - for (refs = submodule_ref_stores; refs; refs = refs->next) {
1406 - if (!strcmp(submodule, refs->submodule))
1407 - return refs;
1408 - }
1409 -
1410 - return NULL;
1411 -}
1412 -
1390 struct ref_store *get_ref_store(const char *submodule)
1391 {
1392 struct ref_store *refs;
@@ -1435,6 +1412,29 @@ struct ref_store *get_ref_store(const char *submodule)
1412 return refs;
1413 }
1414
1415 +void base_ref_store_init(struct ref_store *refs,
1416 + const struct ref_storage_be *be,
1417 + const char *submodule)
1418 +{
1419 + refs->be = be;
1420 + if (!submodule) {
1421 + if (main_ref_store)
1422 + die("BUG: main_ref_store initialized twice");
1423 +
1424 + refs->submodule = "";
1425 + refs->next = NULL;
1426 + main_ref_store = refs;
1427 + } else {
1428 + if (lookup_ref_store(submodule))
1429 + die("BUG: ref_store for submodule '%s' initialized twice",
1430 + submodule);
1431 +
1432 + refs->submodule = xstrdup(submodule);
1433 + refs->next = submodule_ref_stores;
1434 + submodule_ref_stores = refs;
1435 + }
1436 +}
1437 +
1438 void assert_main_repository(struct ref_store *refs, const char *caller)
1439 {
1440 if (*refs->submodule)