Skip to content

Commit e9d882b

Browse files
chriscoolgitster
authored andcommitted
upload-pack: change multi_ack to an enum
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's take this opportunity to change the 'multi_ack' variable, which is now part of 'upload_pack_data', to an enum. This will make it clear which values this variable can take. Helped-by: Jonathan Tan <[email protected]> Signed-off-by: Christian Couder <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 53d6950 commit e9d882b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

upload-pack.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ struct upload_pack_data {
8080
int deepen_relative;
8181

8282
unsigned int timeout; /* v0 only */
83-
int multi_ack; /* v0 only */
83+
enum {
84+
NO_MULTI_ACK = 0,
85+
MULTI_ACK = 1,
86+
MULTI_ACK_DETAILED = 2
87+
} multi_ack; /* v0 only */
8488

8589
/* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */
8690
int use_sideband;
@@ -441,7 +445,7 @@ static int get_common_commits(struct upload_pack_data *data,
441445
reset_timeout(data->timeout);
442446

443447
if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
444-
if (data->multi_ack == 2
448+
if (data->multi_ack == MULTI_ACK_DETAILED
445449
&& got_common
446450
&& !got_other
447451
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
@@ -468,7 +472,7 @@ static int get_common_commits(struct upload_pack_data *data,
468472
if (data->multi_ack
469473
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
470474
const char *hex = oid_to_hex(&oid);
471-
if (data->multi_ack == 2) {
475+
if (data->multi_ack == MULTI_ACK_DETAILED) {
472476
sent_ready = 1;
473477
packet_write_fmt(1, "ACK %s ready\n", hex);
474478
} else
@@ -478,7 +482,7 @@ static int get_common_commits(struct upload_pack_data *data,
478482
default:
479483
got_common = 1;
480484
oid_to_hex_r(last_hex, &oid);
481-
if (data->multi_ack == 2)
485+
if (data->multi_ack == MULTI_ACK_DETAILED)
482486
packet_write_fmt(1, "ACK %s common\n", last_hex);
483487
else if (data->multi_ack)
484488
packet_write_fmt(1, "ACK %s continue\n", last_hex);
@@ -958,9 +962,9 @@ static void receive_needs(struct upload_pack_data *data,
958962
if (parse_feature_request(features, "deepen-relative"))
959963
data->deepen_relative = 1;
960964
if (parse_feature_request(features, "multi_ack_detailed"))
961-
data->multi_ack = 2;
965+
data->multi_ack = MULTI_ACK_DETAILED;
962966
else if (parse_feature_request(features, "multi_ack"))
963-
data->multi_ack = 1;
967+
data->multi_ack = MULTI_ACK;
964968
if (parse_feature_request(features, "no-done"))
965969
data->no_done = 1;
966970
if (parse_feature_request(features, "thin-pack"))

0 commit comments

Comments
 (0)