Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- refs.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/refs.c b/refs.c index c6af84357..c3bdc99d8 100644 --- a/refs.c +++ b/refs.c @@ -1450,15 +1450,23 @@ static struct ref_store *ref_store_init(const char *submodule) return refs; } +static struct ref_store *get_main_ref_store(void) +{ + struct ref_store *refs; + + if (main_ref_store) + return main_ref_store; + + refs = ref_store_init(NULL); + return refs; +} + 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.157.gd943d85