refs.c: introduce get_main_ref_store()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Mar 26, 2017 at 09:42 UTC 24c8407e0aab839a2de57573fd6dd6320f172af3
1 file changed +9 -4
refs.c
+9 -4
@@ -1456,15 +1456,20 @@ static struct ref_store *ref_store_init(const char *submodule)
1456 return refs;
1457 }
1458
1459 +static struct ref_store *get_main_ref_store(void)
1460 +{
1461 + if (main_ref_store)
1462 + return main_ref_store;
1463 +
1464 + return ref_store_init(NULL);
1465 +}
1466 +
1467 struct ref_store *get_ref_store(const char *submodule)
1468 {
1469 struct ref_store *refs;
1470
1471 if (!submodule || !*submodule) {
1464 - refs = lookup_ref_store(NULL);
1465 -
1466 - if (!refs)
1467 - refs = ref_store_init(NULL);
1472 + return get_main_ref_store();
1473 } else {
1474 refs = lookup_ref_store(submodule);
1475