#include "pathspec.h"
#include "submodule.h"
#include "submodule-config.h"
+#include "object-store.h"
static char const * const grep_usage[] = {
N_("git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]"),
* object.
*/
grep_read_lock();
- add_to_alternates_memory(submodule.objectdir);
+ add_to_alternates_memory(submodule.objects->objectdir);
grep_read_unlock();
if (oid) {
#include "fmt-merge-msg.h"
#include "commit.h"
#include "argv-array.h"
+#include "object-store.h"
int trust_executable_bit = 1;
int trust_ctime = 1;
char *get_object_directory(void)
{
- if (!the_repository->objectdir)
+ if (!the_repository->objects->objectdir)
BUG("git environment hasn't been setup");
- return the_repository->objectdir;
+ return the_repository->objects->objectdir;
}
int odb_mkstemp(struct strbuf *template, const char *pattern)
--- /dev/null
+#ifndef OBJECT_STORE_H
+#define OBJECT_STORE_H
+
+struct raw_object_store {
+ /*
+ * Path to the repository's object store.
+ * Cannot be NULL after initialization.
+ */
+ char *objectdir;
+
+ /* Path to extra alternate object database if not NULL */
+ char *alternate_db;
+};
+
+struct raw_object_store *raw_object_store_new(void);
+void raw_object_store_clear(struct raw_object_store *o);
+
+#endif /* OBJECT_STORE_H */
#include "tree.h"
#include "commit.h"
#include "tag.h"
+#include "object-store.h"
static struct object **obj_hash;
static int nr_objs, obj_hash_size;
obj->flags &= ~flags;
}
}
+
+struct raw_object_store *raw_object_store_new(void)
+{
+ struct raw_object_store *o = xmalloc(sizeof(*o));
+
+ memset(o, 0, sizeof(*o));
+ return o;
+}
+void raw_object_store_clear(struct raw_object_store *o)
+{
+ FREE_AND_NULL(o->objectdir);
+ FREE_AND_NULL(o->alternate_db);
+}
#include "submodule-config.h"
#include "path.h"
#include "packfile.h"
+#include "object-store.h"
static int get_st_mode_bits(const char *path, int *mode)
{
strbuf_splice(buf, 0, buf->len,
repo->index_file, strlen(repo->index_file));
else if (dir_prefix(base, "objects"))
- replace_dir(buf, git_dir_len + 7, repo->objectdir);
+ replace_dir(buf, git_dir_len + 7, repo->objects->objectdir);
else if (git_hooks_path && dir_prefix(base, "hooks"))
replace_dir(buf, git_dir_len + 5, git_hooks_path);
else if (repo->different_commondir)
#include "cache.h"
#include "repository.h"
+#include "object-store.h"
#include "config.h"
#include "submodule-config.h"
the_repository = &the_repo;
the_repo.index = &the_index;
+ the_repo.objects = raw_object_store_new();
repo_set_hash_algo(&the_repo, GIT_HASH_SHA1);
}
free(old_gitdir);
repo_set_commondir(repo, o->commondir);
- expand_base_dir(&repo->objectdir, o->object_dir,
+ expand_base_dir(&repo->objects->objectdir, o->object_dir,
repo->commondir, "objects");
- free(repo->alternate_db);
- repo->alternate_db = xstrdup_or_null(o->alternate_db);
+ free(repo->objects->alternate_db);
+ repo->objects->alternate_db = xstrdup_or_null(o->alternate_db);
expand_base_dir(&repo->graft_file, o->graft_file,
repo->commondir, "info/grafts");
expand_base_dir(&repo->index_file, o->index_file,
struct repository_format format;
memset(repo, 0, sizeof(*repo));
+ repo->objects = raw_object_store_new();
+
if (repo_init_gitdir(repo, gitdir))
goto error;
{
FREE_AND_NULL(repo->gitdir);
FREE_AND_NULL(repo->commondir);
- FREE_AND_NULL(repo->objectdir);
- FREE_AND_NULL(repo->alternate_db);
FREE_AND_NULL(repo->graft_file);
FREE_AND_NULL(repo->index_file);
FREE_AND_NULL(repo->worktree);
FREE_AND_NULL(repo->submodule_prefix);
+ raw_object_store_clear(repo->objects);
+ FREE_AND_NULL(repo->objects);
+
if (repo->config) {
git_configset_clear(repo->config);
FREE_AND_NULL(repo->config);
#define REPOSITORY_H
struct config_set;
+struct git_hash_algo;
struct index_state;
+struct raw_object_store;
struct submodule_cache;
-struct git_hash_algo;
struct repository {
/* Environment */
char *commondir;
/*
- * Path to the repository's object store.
- * Cannot be NULL after initialization.
+ * Holds any information related to accessing the raw object content.
*/
- char *objectdir;
-
- /* Path to extra alternate object database if not NULL */
- char *alternate_db;
+ struct raw_object_store *objects;
/*
* Path to the repository's graft file.
#include "quote.h"
#include "packfile.h"
#include "fetch-object.h"
+#include "object-store.h"
const unsigned char null_sha1[GIT_MAX_RAWSZ];
const struct object_id null_oid;
return;
alt_odb_tail = &alt_odb_list;
- link_alt_odb_entries(the_repository->alternate_db, PATH_SEP, NULL, 0);
+ link_alt_odb_entries(the_repository->objects->alternate_db,
+ PATH_SEP, NULL, 0);
read_info_alternates(get_object_directory(), 0);
}