summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c129
1 files changed, 15 insertions, 114 deletions
diff --git a/object.c b/object.c
index 100bf9b8d1..c1553ee433 100644
--- a/object.c
+++ b/object.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
@@ -7,25 +6,23 @@
#include "object.h"
#include "replace-object.h"
#include "object-file.h"
-#include "object-store.h"
#include "blob.h"
#include "statinfo.h"
#include "tree.h"
#include "commit.h"
#include "tag.h"
#include "alloc.h"
-#include "packfile.h"
#include "commit-graph.h"
-#include "loose.h"
-unsigned int get_max_object_index(void)
+unsigned int get_max_object_index(const struct repository *repo)
{
- return the_repository->parsed_objects->obj_hash_size;
+ return repo->parsed_objects->obj_hash_size;
}
-struct object *get_indexed_object(unsigned int idx)
+struct object *get_indexed_object(const struct repository *repo,
+ unsigned int idx)
{
- return the_repository->parsed_objects->obj_hash[idx];
+ return repo->parsed_objects->obj_hash[idx];
}
static const char *object_type_strings[] = {
@@ -217,7 +214,7 @@ enum peel_status peel_object(struct repository *r,
struct object *o = lookup_unknown_object(r, name);
if (o->type == OBJ_NONE) {
- int type = oid_object_info(r, name, NULL);
+ int type = odb_read_object_info(r->objects, name, NULL);
if (type < 0 || !object_as_type(o, type, 0))
return PEEL_INVALID;
}
@@ -283,10 +280,11 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id
return obj;
}
-struct object *parse_object_or_die(const struct object_id *oid,
+struct object *parse_object_or_die(struct repository *repo,
+ const struct object_id *oid,
const char *name)
{
- struct object *o = parse_object(the_repository, oid);
+ struct object *o = parse_object(repo, oid);
if (o)
return o;
@@ -317,7 +315,7 @@ struct object *parse_object_with_flags(struct repository *r,
}
if ((!obj || obj->type == OBJ_BLOB) &&
- oid_object_info(r, oid, NULL) == OBJ_BLOB) {
+ odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {
if (!skip_hash && stream_object_signature(r, repl) < 0) {
error(_("hash mismatch %s"), oid_to_hex(oid));
return NULL;
@@ -333,11 +331,11 @@ struct object *parse_object_with_flags(struct repository *r,
*/
if (skip_hash && discard_tree &&
(!obj || obj->type == OBJ_TREE) &&
- oid_object_info(r, oid, NULL) == OBJ_TREE) {
+ odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) {
return &lookup_tree(r, oid)->object;
}
- buffer = repo_read_object_file(r, oid, &type, &size);
+ buffer = odb_read_object(r->objects, oid, &type, &size);
if (buffer) {
if (!skip_hash &&
check_object_signature(r, repl, buffer, size, type) < 0) {
@@ -491,45 +489,12 @@ void object_array_clear(struct object_array *array)
array->nr = array->alloc = 0;
}
-/*
- * Return true if array already contains an entry.
- */
-static int contains_object(struct object_array *array,
- const struct object *item, const char *name)
-{
- unsigned nr = array->nr, i;
- struct object_array_entry *object = array->objects;
-
- for (i = 0; i < nr; i++, object++)
- if (item == object->item && !strcmp(object->name, name))
- return 1;
- return 0;
-}
-
-void object_array_remove_duplicates(struct object_array *array)
-{
- unsigned nr = array->nr, src;
- struct object_array_entry *objects = array->objects;
-
- array->nr = 0;
- for (src = 0; src < nr; src++) {
- if (!contains_object(array, objects[src].item,
- objects[src].name)) {
- if (src != array->nr)
- objects[array->nr] = objects[src];
- array->nr++;
- } else {
- object_array_release_entry(&objects[src]);
- }
- }
-}
-
-void clear_object_flags(unsigned flags)
+void clear_object_flags(struct repository *repo, unsigned flags)
{
int i;
- for (i=0; i < the_repository->parsed_objects->obj_hash_size; i++) {
- struct object *obj = the_repository->parsed_objects->obj_hash[i];
+ for (i = 0; i < repo->parsed_objects->obj_hash_size; i++) {
+ struct object *obj = repo->parsed_objects->obj_hash[i];
if (obj)
obj->flags &= ~flags;
}
@@ -566,70 +531,6 @@ struct parsed_object_pool *parsed_object_pool_new(struct repository *repo)
return o;
}
-struct raw_object_store *raw_object_store_new(void)
-{
- struct raw_object_store *o = xmalloc(sizeof(*o));
-
- memset(o, 0, sizeof(*o));
- INIT_LIST_HEAD(&o->packed_git_mru);
- hashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);
- pthread_mutex_init(&o->replace_mutex, NULL);
- return o;
-}
-
-void free_object_directory(struct object_directory *odb)
-{
- free(odb->path);
- odb_clear_loose_cache(odb);
- loose_object_map_clear(&odb->loose_map);
- free(odb);
-}
-
-static void free_object_directories(struct raw_object_store *o)
-{
- while (o->odb) {
- struct object_directory *next;
-
- next = o->odb->next;
- free_object_directory(o->odb);
- o->odb = next;
- }
- kh_destroy_odb_path_map(o->odb_by_path);
- o->odb_by_path = NULL;
-}
-
-void raw_object_store_clear(struct raw_object_store *o)
-{
- FREE_AND_NULL(o->alternate_db);
-
- oidmap_free(o->replace_map, 1);
- FREE_AND_NULL(o->replace_map);
- pthread_mutex_destroy(&o->replace_mutex);
-
- free_commit_graph(o->commit_graph);
- o->commit_graph = NULL;
- o->commit_graph_attempted = 0;
-
- free_object_directories(o);
- o->odb_tail = NULL;
- o->loaded_alternates = 0;
-
- INIT_LIST_HEAD(&o->packed_git_mru);
- close_object_store(o);
-
- /*
- * `close_object_store()` only closes the packfiles, but doesn't free
- * them. We thus have to do this manually.
- */
- for (struct packed_git *p = o->packed_git, *next; p; p = next) {
- next = p->next;
- free(p);
- }
- o->packed_git = NULL;
-
- hashmap_clear(&o->pack_map);
-}
-
void parsed_object_pool_reset_commit_grafts(struct parsed_object_pool *o)
{
for (int i = 0; i < o->grafts_nr; i++) {