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 <jonathantanmy@google.com> 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
e9d882b81e8a2f63f7a58f6717e0c1e2a6a62b6d
1 file changed
+10
-6
upload-pack.c
+10
-6
@@ -80,7 +80,11 @@ struct upload_pack_data {
80
int deepen_relative;
81
82
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 */
88
89
/* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */
90
int use_sideband;
@@ -441,7 +445,7 @@ static int get_common_commits(struct upload_pack_data *data,
445
reset_timeout(data->timeout);
446
447
if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
444
- if (data->multi_ack == 2
448
+ if (data->multi_ack == MULTI_ACK_DETAILED
449
&& got_common
450
&& !got_other
451
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
@@ -468,7 +472,7 @@ static int get_common_commits(struct upload_pack_data *data,
472
if (data->multi_ack
473
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
474
const char *hex = oid_to_hex(&oid);
471
- if (data->multi_ack == 2) {
475
+ if (data->multi_ack == MULTI_ACK_DETAILED) {
476
sent_ready = 1;
477
packet_write_fmt(1, "ACK %s ready\n", hex);
478
} else
@@ -478,7 +482,7 @@ static int get_common_commits(struct upload_pack_data *data,
482
default:
483
got_common = 1;
484
oid_to_hex_r(last_hex, &oid);
481
- if (data->multi_ack == 2)
485
+ if (data->multi_ack == MULTI_ACK_DETAILED)
486
packet_write_fmt(1, "ACK %s common\n", last_hex);
487
else if (data->multi_ack)
488
packet_write_fmt(1, "ACK %s continue\n", last_hex);
@@ -958,9 +962,9 @@ static void receive_needs(struct upload_pack_data *data,
962
if (parse_feature_request(features, "deepen-relative"))
963
data->deepen_relative = 1;
964
if (parse_feature_request(features, "multi_ack_detailed"))
961
- data->multi_ack = 2;
965
+ data->multi_ack = MULTI_ACK_DETAILED;
966
else if (parse_feature_request(features, "multi_ack"))
963
- data->multi_ack = 1;
967
+ data->multi_ack = MULTI_ACK;
968
if (parse_feature_request(features, "no-done"))
969
data->no_done = 1;
970
if (parse_feature_request(features, "thin-pack"))