upload-pack: move extra_edge_obj to upload_pack_data
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'extra_edge_obj' static variable into this struct. It is used by code common to protocol v0 and protocol v2. While at it let's properly initialize and clear 'extra_edge_obj' in the appropriate 'upload_pack_data' initialization and clearing functions. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jun 11, 2020 at 14:05 UTC
de0e9f74984b9413680e3903c33e270d8a6b5f69
1 file changed
+7
-4
upload-pack.c
+7
-4
@@ -51,7 +51,6 @@ static timestamp_t oldest_have;
51
/* Allow request of any sha1. Implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. */
52
#define ALLOW_ANY_SHA1 07
53
static unsigned int allow_unadvertised_object_request;
54
-static struct object_array extra_edge_obj;
54
55
/*
56
* Please annotate, and if possible group together, fields used only
@@ -66,6 +65,7 @@ struct upload_pack_data {
65
66
struct object_array shallows;
67
struct string_list deepen_not;
68
+ struct object_array extra_edge_obj;
69
int depth;
70
timestamp_t deepen_since;
71
int deepen_rev_list;
@@ -114,6 +114,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
114
struct oid_array haves = OID_ARRAY_INIT;
115
struct object_array shallows = OBJECT_ARRAY_INIT;
116
struct string_list deepen_not = STRING_LIST_INIT_DUP;
117
+ struct object_array extra_edge_obj = OBJECT_ARRAY_INIT;
118
119
memset(data, 0, sizeof(*data));
120
data->symref = symref;
@@ -123,6 +124,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
124
data->haves = haves;
125
data->shallows = shallows;
126
data->deepen_not = deepen_not;
127
+ data->extra_edge_obj = extra_edge_obj;
128
packet_writer_init(&data->writer, 1);
129
130
data->keepalive = 5;
@@ -137,6 +139,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
139
oid_array_clear(&data->haves);
140
object_array_clear(&data->shallows);
141
string_list_clear(&data->deepen_not, 0);
142
+ object_array_clear(&data->extra_edge_obj);
143
list_objects_filter_release(&data->filter_options);
144
145
free((char *)data->pack_objects_hook);
@@ -243,9 +246,9 @@ static void create_pack_file(struct upload_pack_data *pack_data)
246
for (i = 0; i < pack_data->have_obj.nr; i++)
247
fprintf(pipe_fd, "%s\n",
248
oid_to_hex(&pack_data->have_obj.objects[i].item->oid));
246
- for (i = 0; i < extra_edge_obj.nr; i++)
249
+ for (i = 0; i < pack_data->extra_edge_obj.nr; i++)
250
fprintf(pipe_fd, "%s\n",
248
- oid_to_hex(&extra_edge_obj.objects[i].item->oid));
251
+ oid_to_hex(&pack_data->extra_edge_obj.objects[i].item->oid));
252
fprintf(pipe_fd, "\n");
253
fflush(pipe_fd);
254
fclose(pipe_fd);
@@ -742,7 +745,7 @@ static void send_unshallow(struct upload_pack_data *data)
745
NULL, &data->want_obj);
746
parents = parents->next;
747
}
745
- add_object_array(object, NULL, &extra_edge_obj);
748
+ add_object_array(object, NULL, &data->extra_edge_obj);
749
}
750
/* make sure commit traversal conforms to client */
751
register_shallow(the_repository, &object->oid);