Skip to content

Commit de0e9f7

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 35b43a1 commit de0e9f7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

upload-pack.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ static timestamp_t oldest_have;
5151
/* Allow request of any sha1. Implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. */
5252
#define ALLOW_ANY_SHA1 07
5353
static unsigned int allow_unadvertised_object_request;
54-
static struct object_array extra_edge_obj;
5554

5655
/*
5756
* Please annotate, and if possible group together, fields used only
@@ -66,6 +65,7 @@ struct upload_pack_data {
6665

6766
struct object_array shallows;
6867
struct string_list deepen_not;
68+
struct object_array extra_edge_obj;
6969
int depth;
7070
timestamp_t deepen_since;
7171
int deepen_rev_list;
@@ -114,6 +114,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
114114
struct oid_array haves = OID_ARRAY_INIT;
115115
struct object_array shallows = OBJECT_ARRAY_INIT;
116116
struct string_list deepen_not = STRING_LIST_INIT_DUP;
117+
struct object_array extra_edge_obj = OBJECT_ARRAY_INIT;
117118

118119
memset(data, 0, sizeof(*data));
119120
data->symref = symref;
@@ -123,6 +124,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
123124
data->haves = haves;
124125
data->shallows = shallows;
125126
data->deepen_not = deepen_not;
127+
data->extra_edge_obj = extra_edge_obj;
126128
packet_writer_init(&data->writer, 1);
127129

128130
data->keepalive = 5;
@@ -137,6 +139,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
137139
oid_array_clear(&data->haves);
138140
object_array_clear(&data->shallows);
139141
string_list_clear(&data->deepen_not, 0);
142+
object_array_clear(&data->extra_edge_obj);
140143
list_objects_filter_release(&data->filter_options);
141144

142145
free((char *)data->pack_objects_hook);
@@ -243,9 +246,9 @@ static void create_pack_file(struct upload_pack_data *pack_data)
243246
for (i = 0; i < pack_data->have_obj.nr; i++)
244247
fprintf(pipe_fd, "%s\n",
245248
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++)
247250
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));
249252
fprintf(pipe_fd, "\n");
250253
fflush(pipe_fd);
251254
fclose(pipe_fd);
@@ -742,7 +745,7 @@ static void send_unshallow(struct upload_pack_data *data)
742745
NULL, &data->want_obj);
743746
parents = parents->next;
744747
}
745-
add_object_array(object, NULL, &extra_edge_obj);
748+
add_object_array(object, NULL, &data->extra_edge_obj);
746749
}
747750
/* make sure commit traversal conforms to client */
748751
register_shallow(the_repository, &object->oid);

0 commit comments

Comments
 (0)