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>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2017-03-26 09:42:25 +07:00 коммит произвёл Junio C Hamano
Родитель f57f37e2e1
Коммит 24c8407e0a
1 изменённых файлов: 9 добавлений и 4 удалений

13
refs.c
Просмотреть файл

@ -1456,15 +1456,20 @@ static struct ref_store *ref_store_init(const char *submodule)
return refs;
}
static struct ref_store *get_main_ref_store(void)
{
if (main_ref_store)
return main_ref_store;
return ref_store_init(NULL);
}
struct ref_store *get_ref_store(const char *submodule)
{
struct ref_store *refs;
if (!submodule || !*submodule) {
refs = lookup_ref_store(NULL);
if (!refs)
refs = ref_store_init(NULL);
return get_main_ref_store();
} else {
refs = lookup_ref_store(submodule);