@matheusbsbs / matheus-bagliano / commits / c9f0325905
Fork 0

upload-pack: pass upload_pack_data to create_pack_file()

As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's pass that struct to create_pack_file(), so that this function, and the function it calls, can use all the fields of the struct. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed May 15, 2020 at 12:04 UTC c9f0325905f93323f52a56d1e2b3349489740ed4
1 file changed +9 -15
upload-pack.c
+9 -15
@@ -161,9 +161,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
161 return 0;
162 }
163
164 -static void create_pack_file(const struct object_array *have_obj,
165 - const struct object_array *want_obj,
166 - struct list_objects_filter_options *filter_options)
164 +static void create_pack_file(struct upload_pack_data *pack_data)
165 {
166 struct child_process pack_objects = CHILD_PROCESS_INIT;
167 char data[8193], progress[128];
@@ -200,9 +198,9 @@ static void create_pack_file(const struct object_array *have_obj,
198 argv_array_push(&pack_objects.args, "--delta-base-offset");
199 if (use_include_tag)
200 argv_array_push(&pack_objects.args, "--include-tag");
203 - if (filter_options->choice) {
201 + if (pack_data->filter_options.choice) {
202 const char *spec =
205 - expand_list_objects_filter_spec(filter_options);
203 + expand_list_objects_filter_spec(&pack_data->filter_options);
204 if (pack_objects.use_shell) {
205 struct strbuf buf = STRBUF_INIT;
206 sq_quote_buf(&buf, spec);
@@ -226,13 +224,13 @@ static void create_pack_file(const struct object_array *have_obj,
224 if (shallow_nr)
225 for_each_commit_graft(write_one_shallow, pipe_fd);
226
229 - for (i = 0; i < want_obj->nr; i++)
227 + for (i = 0; i < pack_data->want_obj.nr; i++)
228 fprintf(pipe_fd, "%s\n",
231 - oid_to_hex(&want_obj->objects[i].item->oid));
229 + oid_to_hex(&pack_data->want_obj.objects[i].item->oid));
230 fprintf(pipe_fd, "--not\n");
233 - for (i = 0; i < have_obj->nr; i++)
231 + for (i = 0; i < pack_data->have_obj.nr; i++)
232 fprintf(pipe_fd, "%s\n",
235 - oid_to_hex(&have_obj->objects[i].item->oid));
233 + oid_to_hex(&pack_data->have_obj.objects[i].item->oid));
234 for (i = 0; i < extra_edge_obj.nr; i++)
235 fprintf(pipe_fd, "%s\n",
236 oid_to_hex(&extra_edge_obj.objects[i].item->oid));
@@ -1179,9 +1177,7 @@ void upload_pack(struct upload_pack_options *options)
1177 receive_needs(&data, &reader);
1178 if (data.want_obj.nr) {
1179 get_common_commits(&data, &reader);
1182 - create_pack_file(&data.have_obj,
1183 - &data.want_obj,
1184 - &data.filter_options);
1180 + create_pack_file(&data);
1181 }
1182 }
1183
@@ -1525,9 +1521,7 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys,
1521 send_shallow_info(&data);
1522
1523 packet_writer_write(&data.writer, "packfile\n");
1528 - create_pack_file(&data.have_obj,
1529 - &data.want_obj,
1530 - &data.filter_options);
1524 + create_pack_file(&data);
1525 state = FETCH_DONE;
1526 break;
1527 case FETCH_DONE: