Skip to content

Commit 0797769

Browse files
chriscoolgitster
authored andcommitted
upload-pack: pass upload_pack_data to get_common_commits()
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's pass 'struct upload_pack_data' to get_common_commits(), so that this function and the functions it calls can use all the fields of that struct in followup commits. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebf8ebc commit 0797769

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

upload-pack.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,8 @@ static int ok_to_give_up(const struct object_array *have_obj,
414414
min_generation);
415415
}
416416

417-
static int get_common_commits(struct packet_reader *reader,
418-
struct object_array *have_obj,
419-
struct object_array *want_obj)
417+
static int get_common_commits(struct upload_pack_data *data,
418+
struct packet_reader *reader)
420419
{
421420
struct object_id oid;
422421
char last_hex[GIT_MAX_HEXSZ + 1];
@@ -432,12 +431,14 @@ static int get_common_commits(struct packet_reader *reader,
432431
reset_timeout();
433432

434433
if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
435-
if (multi_ack == 2 && got_common
436-
&& !got_other && ok_to_give_up(have_obj, want_obj)) {
434+
if (multi_ack == 2
435+
&& got_common
436+
&& !got_other
437+
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
437438
sent_ready = 1;
438439
packet_write_fmt(1, "ACK %s ready\n", last_hex);
439440
}
440-
if (have_obj->nr == 0 || multi_ack)
441+
if (data->have_obj.nr == 0 || multi_ack)
441442
packet_write_fmt(1, "NAK\n");
442443

443444
if (no_done && sent_ready) {
@@ -451,10 +452,11 @@ static int get_common_commits(struct packet_reader *reader,
451452
continue;
452453
}
453454
if (skip_prefix(reader->line, "have ", &arg)) {
454-
switch (got_oid(arg, &oid, have_obj)) {
455+
switch (got_oid(arg, &oid, &data->have_obj)) {
455456
case -1: /* they have what we do not */
456457
got_other = 1;
457-
if (multi_ack && ok_to_give_up(have_obj, want_obj)) {
458+
if (multi_ack
459+
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
458460
const char *hex = oid_to_hex(&oid);
459461
if (multi_ack == 2) {
460462
sent_ready = 1;
@@ -470,14 +472,14 @@ static int get_common_commits(struct packet_reader *reader,
470472
packet_write_fmt(1, "ACK %s common\n", last_hex);
471473
else if (multi_ack)
472474
packet_write_fmt(1, "ACK %s continue\n", last_hex);
473-
else if (have_obj->nr == 1)
475+
else if (data->have_obj.nr == 1)
474476
packet_write_fmt(1, "ACK %s\n", last_hex);
475477
break;
476478
}
477479
continue;
478480
}
479481
if (!strcmp(reader->line, "done")) {
480-
if (have_obj->nr > 0) {
482+
if (data->have_obj.nr > 0) {
481483
if (multi_ack)
482484
packet_write_fmt(1, "ACK %s\n", last_hex);
483485
return 0;
@@ -1176,9 +1178,7 @@ void upload_pack(struct upload_pack_options *options)
11761178

11771179
receive_needs(&reader, &data.want_obj, &data.filter_options);
11781180
if (data.want_obj.nr) {
1179-
get_common_commits(&reader,
1180-
&data.have_obj,
1181-
&data.want_obj);
1181+
get_common_commits(&data, &reader);
11821182
create_pack_file(&data.have_obj,
11831183
&data.want_obj,
11841184
&data.filter_options);

0 commit comments

Comments
 (0)