@matheusbsbs / matheus-bagliano / commits / 6fbbc4374f
Fork 0

upload-pack: pass upload_pack_data to send_acks()

As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's pass that struct to send_acks(), so that this function can use all the fields of the struct. This will be used in followup commits to move a static variable into 'upload_pack_data'. 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 6fbbc4374f79deb2ebabdd60e46364df39ea5f62
1 file changed +7 -10
upload-pack.c
+7 -10
@@ -1387,26 +1387,24 @@ static int process_haves(struct upload_pack_data *data, struct oid_array *common
1387 return 0;
1388 }
1389
1390 -static int send_acks(struct packet_writer *writer, struct oid_array *acks,
1391 - const struct object_array *have_obj,
1392 - struct object_array *want_obj)
1390 +static int send_acks(struct upload_pack_data *data, struct oid_array *acks)
1391 {
1392 int i;
1393
1396 - packet_writer_write(writer, "acknowledgments\n");
1394 + packet_writer_write(&data->writer, "acknowledgments\n");
1395
1396 /* Send Acks */
1397 if (!acks->nr)
1400 - packet_writer_write(writer, "NAK\n");
1398 + packet_writer_write(&data->writer, "NAK\n");
1399
1400 for (i = 0; i < acks->nr; i++) {
1403 - packet_writer_write(writer, "ACK %s\n",
1401 + packet_writer_write(&data->writer, "ACK %s\n",
1402 oid_to_hex(&acks->oid[i]));
1403 }
1404
1407 - if (ok_to_give_up(have_obj, want_obj)) {
1405 + if (ok_to_give_up(&data->have_obj, &data->want_obj)) {
1406 /* Send Ready */
1409 - packet_writer_write(writer, "ready\n");
1407 + packet_writer_write(&data->writer, "ready\n");
1408 return 1;
1409 }
1410
@@ -1421,8 +1419,7 @@ static int process_haves_and_send_acks(struct upload_pack_data *data)
1419 process_haves(data, &common);
1420 if (data->done) {
1421 ret = 1;
1424 - } else if (send_acks(&data->writer, &common,
1425 - &data->have_obj, &data->want_obj)) {
1422 + } else if (send_acks(data, &common)) {
1423 packet_writer_delim(&data->writer);
1424 ret = 1;
1425 } else {