Skip to content

Commit 0866734

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

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

upload-pack.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,15 +428,14 @@ static int got_oid(const char *hex, struct object_id *oid,
428428
return 0;
429429
}
430430

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)
433432
{
434433
uint32_t min_generation = GENERATION_NUMBER_ZERO;
435434

436-
if (!have_obj->nr)
435+
if (!data->have_obj.nr)
437436
return 0;
438437

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,
440439
COMMON_KNOWN, oldest_have,
441440
min_generation);
442441
}
@@ -461,7 +460,7 @@ static int get_common_commits(struct upload_pack_data *data,
461460
if (data->multi_ack == MULTI_ACK_DETAILED
462461
&& got_common
463462
&& !got_other
464-
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
463+
&& ok_to_give_up(data)) {
465464
sent_ready = 1;
466465
packet_write_fmt(1, "ACK %s ready\n", last_hex);
467466
}
@@ -483,7 +482,7 @@ static int get_common_commits(struct upload_pack_data *data,
483482
case -1: /* they have what we do not */
484483
got_other = 1;
485484
if (data->multi_ack
486-
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
485+
&& ok_to_give_up(data)) {
487486
const char *hex = oid_to_hex(&oid);
488487
if (data->multi_ack == MULTI_ACK_DETAILED) {
489488
sent_ready = 1;
@@ -1402,7 +1401,7 @@ static int send_acks(struct upload_pack_data *data, struct oid_array *acks)
14021401
oid_to_hex(&acks->oid[i]));
14031402
}
14041403

1405-
if (ok_to_give_up(&data->have_obj, &data->want_obj)) {
1404+
if (ok_to_give_up(data)) {
14061405
/* Send Ready */
14071406
packet_writer_write(&data->writer, "ready\n");
14081407
return 1;

0 commit comments

Comments
 (0)