Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-03-23 20:20:55 +0300
committerJunio C Hamano <gitster@pobox.com>2018-03-23 21:06:01 +0300
commit90c62155d65a6bec5c2c293c8ece0b22173f63a3 (patch)
treec4d23c9cae65059849f5e1d39814f3eb34657120 /repository.c
parent00a3da2a131a3e122df7e053d992fbc1735bf4f9 (diff)
repository: introduce raw object store field
The raw object store field will contain any objects needed for access to objects in a given repository. This patch introduces the raw object store and populates it with the `objectdir`, which used to be part of the repository struct. As the struct gains members, we'll also populate the function to clear the memory for these members. In a later step, we'll introduce a struct object_parser, that will complement the object parsing in a repository struct: The raw object parser is the layer that will provide access to raw object content, while the higher level object parser code will parse raw objects and keeps track of parenthood and other object relationships using 'struct object'. For now only add the lower level to the repository struct. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repository.c')
-rw-r--r--repository.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/repository.c b/repository.c
index 62f52f47fc..a4848c1bd0 100644
--- a/repository.c
+++ b/repository.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "repository.h"
+#include "object-store.h"
#include "config.h"
#include "submodule-config.h"
@@ -12,6 +13,7 @@ void initialize_the_repository(void)
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);
}
@@ -58,10 +60,10 @@ void repo_set_gitdir(struct repository *repo,
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,
@@ -140,6 +142,8 @@ static int repo_init(struct repository *repo,
struct repository_format format;
memset(repo, 0, sizeof(*repo));
+ repo->objects = raw_object_store_new();
+
if (repo_init_gitdir(repo, gitdir))
goto error;
@@ -214,13 +218,14 @@ void repo_clear(struct repository *repo)
{
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);