Commit 4e8dc055 by Patrick Steinhardt

pack-objects: make `git_walk_object` internal to pack-objects

The `git_walk_objects` structure is currently only being used inside of
the pack-objects.c file, but being declared in its header. This has
actually been the case since its inception in 04a36fef (pack-objects:
fill a packbuilder from a walk, 2014-10-11) and has never really
changed.

Move the struct declaration into pack-objects.c to improve code
encapsulation.
parent e212011b
...@@ -41,6 +41,12 @@ struct pack_write_context { ...@@ -41,6 +41,12 @@ struct pack_write_context {
git_transfer_progress *stats; git_transfer_progress *stats;
}; };
struct walk_object {
git_oid id;
unsigned int uninteresting:1,
seen:1;
};
#ifdef GIT_THREADS #ifdef GIT_THREADS
#define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) do { \ #define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) do { \
...@@ -143,7 +149,7 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo) ...@@ -143,7 +149,7 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo)
if (!pb->walk_objects) if (!pb->walk_objects)
goto on_error; goto on_error;
git_pool_init(&pb->object_pool, sizeof(git_walk_object)); git_pool_init(&pb->object_pool, sizeof(struct walk_object));
pb->repo = repo; pb->repo = repo;
pb->nr_threads = 1; /* do not spawn any thread by default */ pb->nr_threads = 1; /* do not spawn any thread by default */
...@@ -1513,9 +1519,9 @@ size_t git_packbuilder_written(git_packbuilder *pb) ...@@ -1513,9 +1519,9 @@ size_t git_packbuilder_written(git_packbuilder *pb)
return pb->nr_written; return pb->nr_written;
} }
int lookup_walk_object(git_walk_object **out, git_packbuilder *pb, const git_oid *id) static int lookup_walk_object(struct walk_object **out, git_packbuilder *pb, const git_oid *id)
{ {
git_walk_object *obj; struct walk_object *obj;
obj = git_pool_mallocz(&pb->object_pool, 1); obj = git_pool_mallocz(&pb->object_pool, 1);
if (!obj) { if (!obj) {
...@@ -1529,11 +1535,11 @@ int lookup_walk_object(git_walk_object **out, git_packbuilder *pb, const git_oid ...@@ -1529,11 +1535,11 @@ int lookup_walk_object(git_walk_object **out, git_packbuilder *pb, const git_oid
return 0; return 0;
} }
static int retrieve_object(git_walk_object **out, git_packbuilder *pb, const git_oid *id) static int retrieve_object(struct walk_object **out, git_packbuilder *pb, const git_oid *id)
{ {
int error; int error;
khiter_t pos; khiter_t pos;
git_walk_object *obj; struct walk_object *obj;
pos = git_oidmap_lookup_index(pb->walk_objects, id); pos = git_oidmap_lookup_index(pb->walk_objects, id);
if (git_oidmap_valid_index(pb->walk_objects, pos)) { if (git_oidmap_valid_index(pb->walk_objects, pos)) {
...@@ -1552,7 +1558,7 @@ static int retrieve_object(git_walk_object **out, git_packbuilder *pb, const git ...@@ -1552,7 +1558,7 @@ static int retrieve_object(git_walk_object **out, git_packbuilder *pb, const git
static int mark_blob_uninteresting(git_packbuilder *pb, const git_oid *id) static int mark_blob_uninteresting(git_packbuilder *pb, const git_oid *id)
{ {
int error; int error;
git_walk_object *obj; struct walk_object *obj;
if ((error = retrieve_object(&obj, pb, id)) < 0) if ((error = retrieve_object(&obj, pb, id)) < 0)
return error; return error;
...@@ -1564,7 +1570,7 @@ static int mark_blob_uninteresting(git_packbuilder *pb, const git_oid *id) ...@@ -1564,7 +1570,7 @@ static int mark_blob_uninteresting(git_packbuilder *pb, const git_oid *id)
static int mark_tree_uninteresting(git_packbuilder *pb, const git_oid *id) static int mark_tree_uninteresting(git_packbuilder *pb, const git_oid *id)
{ {
git_walk_object *obj; struct walk_object *obj;
git_tree *tree; git_tree *tree;
int error; int error;
size_t i; size_t i;
...@@ -1636,7 +1642,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree) ...@@ -1636,7 +1642,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
size_t i; size_t i;
int error; int error;
git_tree *subtree; git_tree *subtree;
git_walk_object *obj; struct walk_object *obj;
const char *name; const char *name;
if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0) if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0)
...@@ -1684,7 +1690,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree) ...@@ -1684,7 +1690,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
return error; return error;
} }
int insert_commit(git_packbuilder *pb, git_walk_object *obj) int insert_commit(git_packbuilder *pb, struct walk_object *obj)
{ {
int error; int error;
git_commit *commit = NULL; git_commit *commit = NULL;
...@@ -1714,7 +1720,7 @@ int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk) ...@@ -1714,7 +1720,7 @@ int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk)
{ {
int error; int error;
git_oid id; git_oid id;
git_walk_object *obj; struct walk_object *obj;
assert(pb && walk); assert(pb && walk);
......
...@@ -52,12 +52,6 @@ typedef struct git_pobject { ...@@ -52,12 +52,6 @@ typedef struct git_pobject {
filled:1; filled:1;
} git_pobject; } git_pobject;
typedef struct {
git_oid id;
unsigned int uninteresting:1,
seen:1;
} git_walk_object;
struct git_packbuilder { struct git_packbuilder {
git_repository *repo; /* associated repository */ git_repository *repo; /* associated repository */
git_odb *odb; /* associated object database */ git_odb *odb; /* associated object database */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment