return reinit;
}
- static void create_object_directory(struct repository *repo)
+ static void create_object_database(struct repository *repo)
{
- struct strbuf path = STRBUF_INIT;
- size_t baselen;
+ char *object_directory, *alternate_object_directories;
- strbuf_addstr(&path, repo_get_object_directory(repo));
- baselen = path.len;
+ get_object_directories(&object_directory, &alternate_object_directories);
- safe_create_dir(repo, path.buf, 1);
+ /*
+ * Create the "objects" directory in the common directory. This is done
+ * so that the repository can be discovered regardless of the backend
+ * used.
+ *
+ * Note that we only do this in case the object directory wasn't
+ * overwritten via an environment variable. If it _is_ being overridden
+ * then we skip this step, as the repository won't be discoverable
+ * anyway without the environment variable.
+ */
+ if (!object_directory) {
+ struct strbuf objects_dir = STRBUF_INIT;
+ repo_common_path_append(repo, &objects_dir, "objects");
+ safe_create_dir(repo, objects_dir.buf, 1);
+ strbuf_release(&objects_dir);
+ }
- strbuf_setlen(&path, baselen);
- strbuf_addstr(&path, "/pack");
- safe_create_dir(repo, path.buf, 1);
+ repo->objects = odb_new(repo, object_directory,
+ alternate_object_directories);
- strbuf_setlen(&path, baselen);
- strbuf_addstr(&path, "/info");
- safe_create_dir(repo, path.buf, 1);
+ if (odb_source_create_on_disk(repo->objects->sources) < 0)
+ die("failed creating object database");
- strbuf_release(&path);
+ free(alternate_object_directories);
+ free(object_directory);
}
-static void separate_git_dir(const char *git_dir, const char *git_link)
+static void separate_git_dir(struct repository *repo,
+ const char *git_dir, const char *git_link)
{
struct stat st;