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 04a36feff (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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
diff --git a/src/pack-objects.c b/src/pack-objects.c
index bc5fb2e..c12f25e 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -41,6 +41,12 @@ struct pack_write_context {
git_transfer_progress *stats;
};
+struct walk_object {
+ git_oid id;
+ unsigned int uninteresting:1,
+ seen:1;
+};
+
#ifdef GIT_THREADS
#define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) do { \
@@ -143,7 +149,7 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo)
if (!pb->walk_objects)
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->nr_threads = 1; /* do not spawn any thread by default */
@@ -1513,9 +1519,9 @@ size_t git_packbuilder_written(git_packbuilder *pb)
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);
if (!obj) {
@@ -1529,11 +1535,11 @@ int lookup_walk_object(git_walk_object **out, git_packbuilder *pb, const git_oid
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;
khiter_t pos;
- git_walk_object *obj;
+ struct walk_object *obj;
pos = git_oidmap_lookup_index(pb->walk_objects, id);
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
static int mark_blob_uninteresting(git_packbuilder *pb, const git_oid *id)
{
int error;
- git_walk_object *obj;
+ struct walk_object *obj;
if ((error = retrieve_object(&obj, pb, id)) < 0)
return error;
@@ -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)
{
- git_walk_object *obj;
+ struct walk_object *obj;
git_tree *tree;
int error;
size_t i;
@@ -1636,7 +1642,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
size_t i;
int error;
git_tree *subtree;
- git_walk_object *obj;
+ struct walk_object *obj;
const char *name;
if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0)
@@ -1684,7 +1690,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
return error;
}
-int insert_commit(git_packbuilder *pb, git_walk_object *obj)
+int insert_commit(git_packbuilder *pb, struct walk_object *obj)
{
int error;
git_commit *commit = NULL;
@@ -1714,7 +1720,7 @@ int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk)
{
int error;
git_oid id;
- git_walk_object *obj;
+ struct walk_object *obj;
assert(pb && walk);
diff --git a/src/pack-objects.h b/src/pack-objects.h
index c9cd577..a931f3f 100644
--- a/src/pack-objects.h
+++ b/src/pack-objects.h
@@ -52,12 +52,6 @@ typedef struct git_pobject {
filled:1;
} git_pobject;
-typedef struct {
- git_oid id;
- unsigned int uninteresting:1,
- seen:1;
-} git_walk_object;
-
struct git_packbuilder {
git_repository *repo; /* associated repository */
git_odb *odb; /* associated object database */