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

upload-pack: pass upload_pack_data to ok_to_give_up()

As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's pass that struct to ok_to_give_up(), 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 086673482068391dab193c8ef9c8fefb8176a218
1 file changed +6 -7
upload-pack.c
+6 -7
@@ -428,15 +428,14 @@ static int got_oid(const char *hex, struct object_id *oid,
428 return 0;
429 }
430
431 -static int ok_to_give_up(const struct object_array *have_obj,
432 - struct object_array *want_obj)
431 +static int ok_to_give_up(struct upload_pack_data *data)
432 {
433 uint32_t min_generation = GENERATION_NUMBER_ZERO;
434
436 - if (!have_obj->nr)
435 + if (!data->have_obj.nr)
436 return 0;
437
439 - return can_all_from_reach_with_flag(want_obj, THEY_HAVE,
438 + return can_all_from_reach_with_flag(&data->want_obj, THEY_HAVE,
439 COMMON_KNOWN, oldest_have,
440 min_generation);
441 }
@@ -461,7 +460,7 @@ static int get_common_commits(struct upload_pack_data *data,
460 if (data->multi_ack == MULTI_ACK_DETAILED
461 && got_common
462 && !got_other
464 - && ok_to_give_up(&data->have_obj, &data->want_obj)) {
463 + && ok_to_give_up(data)) {
464 sent_ready = 1;
465 packet_write_fmt(1, "ACK %s ready\n", last_hex);
466 }
@@ -483,7 +482,7 @@ static int get_common_commits(struct upload_pack_data *data,
482 case -1: /* they have what we do not */
483 got_other = 1;
484 if (data->multi_ack
486 - && ok_to_give_up(&data->have_obj, &data->want_obj)) {
485 + && ok_to_give_up(data)) {
486 const char *hex = oid_to_hex(&oid);
487 if (data->multi_ack == MULTI_ACK_DETAILED) {
488 sent_ready = 1;
@@ -1402,7 +1401,7 @@ static int send_acks(struct upload_pack_data *data, struct oid_array *acks)
1401 oid_to_hex(&acks->oid[i]));
1402 }
1403
1405 - if (ok_to_give_up(&data->have_obj, &data->want_obj)) {
1404 + if (ok_to_give_up(data)) {
1405 /* Send Ready */
1406 packet_writer_write(&data->writer, "ready\n");
1407 return 1;