Skip to content

Commit 53d6950

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 59a9026 commit 53d6950

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

upload-pack.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
static timestamp_t oldest_have;
4646

47-
static int multi_ack;
4847
/* Allow specifying sha1 if it is a ref tip. */
4948
#define ALLOW_TIP_SHA1 01
5049
/* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
@@ -81,6 +80,7 @@ struct upload_pack_data {
8180
int deepen_relative;
8281

8382
unsigned int timeout; /* v0 only */
83+
int multi_ack; /* v0 only */
8484

8585
/* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */
8686
int use_sideband;
@@ -441,14 +441,14 @@ static int get_common_commits(struct upload_pack_data *data,
441441
reset_timeout(data->timeout);
442442

443443
if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
444-
if (multi_ack == 2
444+
if (data->multi_ack == 2
445445
&& got_common
446446
&& !got_other
447447
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
448448
sent_ready = 1;
449449
packet_write_fmt(1, "ACK %s ready\n", last_hex);
450450
}
451-
if (data->have_obj.nr == 0 || multi_ack)
451+
if (data->have_obj.nr == 0 || data->multi_ack)
452452
packet_write_fmt(1, "NAK\n");
453453

454454
if (data->no_done && sent_ready) {
@@ -465,10 +465,10 @@ static int get_common_commits(struct upload_pack_data *data,
465465
switch (got_oid(arg, &oid, &data->have_obj)) {
466466
case -1: /* they have what we do not */
467467
got_other = 1;
468-
if (multi_ack
468+
if (data->multi_ack
469469
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
470470
const char *hex = oid_to_hex(&oid);
471-
if (multi_ack == 2) {
471+
if (data->multi_ack == 2) {
472472
sent_ready = 1;
473473
packet_write_fmt(1, "ACK %s ready\n", hex);
474474
} else
@@ -478,9 +478,9 @@ static int get_common_commits(struct upload_pack_data *data,
478478
default:
479479
got_common = 1;
480480
oid_to_hex_r(last_hex, &oid);
481-
if (multi_ack == 2)
481+
if (data->multi_ack == 2)
482482
packet_write_fmt(1, "ACK %s common\n", last_hex);
483-
else if (multi_ack)
483+
else if (data->multi_ack)
484484
packet_write_fmt(1, "ACK %s continue\n", last_hex);
485485
else if (data->have_obj.nr == 1)
486486
packet_write_fmt(1, "ACK %s\n", last_hex);
@@ -490,7 +490,7 @@ static int get_common_commits(struct upload_pack_data *data,
490490
}
491491
if (!strcmp(reader->line, "done")) {
492492
if (data->have_obj.nr > 0) {
493-
if (multi_ack)
493+
if (data->multi_ack)
494494
packet_write_fmt(1, "ACK %s\n", last_hex);
495495
return 0;
496496
}
@@ -958,9 +958,9 @@ static void receive_needs(struct upload_pack_data *data,
958958
if (parse_feature_request(features, "deepen-relative"))
959959
data->deepen_relative = 1;
960960
if (parse_feature_request(features, "multi_ack_detailed"))
961-
multi_ack = 2;
961+
data->multi_ack = 2;
962962
else if (parse_feature_request(features, "multi_ack"))
963-
multi_ack = 1;
963+
data->multi_ack = 1;
964964
if (parse_feature_request(features, "no-done"))
965965
data->no_done = 1;
966966
if (parse_feature_request(features, "thin-pack"))

0 commit comments

Comments
 (0)