@matheusbsbs / matheus-bagliano / commits / 53d69506c1
Fork 0

upload-pack: move multi_ack to upload_pack_data

As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the multi_ack static variable into this struct. It is only used by protocol v0 code since protocol v2 assumes certain baseline capabilities, but rolling it into upload_pack_data and just letting v2 code ignore it as it does now is more coherent and cleaner. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Jun 4, 2020 at 19:54 UTC 53d69506c1108f5d4f7ac2fccd871946ff012071
1 file changed +10 -10
upload-pack.c
+10 -10
@@ -44,7 +44,6 @@
44
45 static timestamp_t oldest_have;
46
47 -static int multi_ack;
47 /* Allow specifying sha1 if it is a ref tip. */
48 #define ALLOW_TIP_SHA1 01
49 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
@@ -81,6 +80,7 @@ struct upload_pack_data {
80 int deepen_relative;
81
82 unsigned int timeout; /* v0 only */
83 + int multi_ack; /* v0 only */
84
85 /* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */
86 int use_sideband;
@@ -441,14 +441,14 @@ static int get_common_commits(struct upload_pack_data *data,
441 reset_timeout(data->timeout);
442
443 if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
444 - if (multi_ack == 2
444 + if (data->multi_ack == 2
445 && got_common
446 && !got_other
447 && ok_to_give_up(&data->have_obj, &data->want_obj)) {
448 sent_ready = 1;
449 packet_write_fmt(1, "ACK %s ready\n", last_hex);
450 }
451 - if (data->have_obj.nr == 0 || multi_ack)
451 + if (data->have_obj.nr == 0 || data->multi_ack)
452 packet_write_fmt(1, "NAK\n");
453
454 if (data->no_done && sent_ready) {
@@ -465,10 +465,10 @@ static int get_common_commits(struct upload_pack_data *data,
465 switch (got_oid(arg, &oid, &data->have_obj)) {
466 case -1: /* they have what we do not */
467 got_other = 1;
468 - if (multi_ack
468 + if (data->multi_ack
469 && ok_to_give_up(&data->have_obj, &data->want_obj)) {
470 const char *hex = oid_to_hex(&oid);
471 - if (multi_ack == 2) {
471 + if (data->multi_ack == 2) {
472 sent_ready = 1;
473 packet_write_fmt(1, "ACK %s ready\n", hex);
474 } else
@@ -478,9 +478,9 @@ static int get_common_commits(struct upload_pack_data *data,
478 default:
479 got_common = 1;
480 oid_to_hex_r(last_hex, &oid);
481 - if (multi_ack == 2)
481 + if (data->multi_ack == 2)
482 packet_write_fmt(1, "ACK %s common\n", last_hex);
483 - else if (multi_ack)
483 + else if (data->multi_ack)
484 packet_write_fmt(1, "ACK %s continue\n", last_hex);
485 else if (data->have_obj.nr == 1)
486 packet_write_fmt(1, "ACK %s\n", last_hex);
@@ -490,7 +490,7 @@ static int get_common_commits(struct upload_pack_data *data,
490 }
491 if (!strcmp(reader->line, "done")) {
492 if (data->have_obj.nr > 0) {
493 - if (multi_ack)
493 + if (data->multi_ack)
494 packet_write_fmt(1, "ACK %s\n", last_hex);
495 return 0;
496 }
@@ -958,9 +958,9 @@ static void receive_needs(struct upload_pack_data *data,
958 if (parse_feature_request(features, "deepen-relative"))
959 data->deepen_relative = 1;
960 if (parse_feature_request(features, "multi_ack_detailed"))
961 - multi_ack = 2;
961 + data->multi_ack = 2;
962 else if (parse_feature_request(features, "multi_ack"))
963 - multi_ack = 1;
963 + data->multi_ack = 1;
964 if (parse_feature_request(features, "no-done"))
965 data->no_done = 1;
966 if (parse_feature_request(features, "thin-pack"))