#include "refs/refs-internal.h"
#include "object.h"
#include "tag.h"
+#include "submodule.h"
/*
* List of all available backends
/*
* 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);
if (!be)
die("BUG: reference backend %s is unknown", be_name);
- refs = be->init(submodule);
+ refs = be->init(gitdir);
return refs;
}
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;
}
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;
}