diff options
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -9,6 +9,7 @@ #include "refs/refs-internal.h" #include "object.h" #include "tag.h" +#include "submodule.h" /* * List of all available backends @@ -1413,9 +1414,9 @@ static struct ref_store *lookup_submodule_ref_store(const char *submodule) /* * Create, record, and return a ref_store instance for the specified - * submodule (or the main repository if submodule is NULL). + * gitdir. */ -static struct ref_store *ref_store_init(const char *submodule) +static struct ref_store *ref_store_init(const char *gitdir) { const char *be_name = "files"; struct ref_storage_be *be = find_ref_storage_backend(be_name); @@ -1424,7 +1425,7 @@ static struct ref_store *ref_store_init(const char *submodule) if (!be) die("BUG: reference backend %s is unknown", be_name); - refs = be->init(submodule); + refs = be->init(gitdir); return refs; } @@ -1433,7 +1434,7 @@ struct ref_store *get_main_ref_store(void) if (main_ref_store) return main_ref_store; - main_ref_store = ref_store_init(NULL); + main_ref_store = ref_store_init(get_git_dir()); return main_ref_store; } @@ -1474,8 +1475,16 @@ struct ref_store *get_ref_store(const char *submodule) if (!ret) return NULL; - refs = ref_store_init(submodule); + ret = submodule_to_gitdir(&submodule_sb, submodule); + if (ret) { + strbuf_release(&submodule_sb); + return NULL; + } + + refs = ref_store_init(submodule_sb.buf); register_submodule_ref_store(refs, submodule); + + strbuf_release(&submodule_sb); return refs; } |