From 24c8407e0aab839a2de57573fd6dd6320f172af3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 26 Mar 2017 09:42:25 +0700 Subject: [PATCH] refs.c: introduce get_main_ref_store() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- refs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/refs.c b/refs.c index e7606716d..8aa33af4e 100644 --- a/refs.c +++ b/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); -- 2.11.0