]> git.ipfire.org Git - thirdparty/git.git/commitdiff
upload-pack: move multi_ack to upload_pack_data
authorChristian Couder <christian.couder@gmail.com>
Thu, 4 Jun 2020 17:54:43 +0000 (19:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Jun 2020 17:58:26 +0000 (10:58 -0700)
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>
upload-pack.c

index 6226387a84329a9dd290ef9cb6865b9c8081446a..f8611a5d5360837199ca4664d39581f7ef29daa1 100644 (file)
@@ -44,7 +44,6 @@
 
 static timestamp_t oldest_have;
 
-static int multi_ack;
 /* Allow specifying sha1 if it is a ref tip. */
 #define ALLOW_TIP_SHA1 01
 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
@@ -81,6 +80,7 @@ struct upload_pack_data {
        int deepen_relative;
 
        unsigned int timeout;                                   /* v0 only */
+       int multi_ack;                                          /* v0 only */
 
        /* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */
        int use_sideband;
@@ -441,14 +441,14 @@ static int get_common_commits(struct upload_pack_data *data,
                reset_timeout(data->timeout);
 
                if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
-                       if (multi_ack == 2
+                       if (data->multi_ack == 2
                            && got_common
                            && !got_other
                            && ok_to_give_up(&data->have_obj, &data->want_obj)) {
                                sent_ready = 1;
                                packet_write_fmt(1, "ACK %s ready\n", last_hex);
                        }
-                       if (data->have_obj.nr == 0 || multi_ack)
+                       if (data->have_obj.nr == 0 || data->multi_ack)
                                packet_write_fmt(1, "NAK\n");
 
                        if (data->no_done && sent_ready) {
@@ -465,10 +465,10 @@ static int get_common_commits(struct upload_pack_data *data,
                        switch (got_oid(arg, &oid, &data->have_obj)) {
                        case -1: /* they have what we do not */
                                got_other = 1;
-                               if (multi_ack
+                               if (data->multi_ack
                                    && ok_to_give_up(&data->have_obj, &data->want_obj)) {
                                        const char *hex = oid_to_hex(&oid);
-                                       if (multi_ack == 2) {
+                                       if (data->multi_ack == 2) {
                                                sent_ready = 1;
                                                packet_write_fmt(1, "ACK %s ready\n", hex);
                                        } else
@@ -478,9 +478,9 @@ static int get_common_commits(struct upload_pack_data *data,
                        default:
                                got_common = 1;
                                oid_to_hex_r(last_hex, &oid);
-                               if (multi_ack == 2)
+                               if (data->multi_ack == 2)
                                        packet_write_fmt(1, "ACK %s common\n", last_hex);
-                               else if (multi_ack)
+                               else if (data->multi_ack)
                                        packet_write_fmt(1, "ACK %s continue\n", last_hex);
                                else if (data->have_obj.nr == 1)
                                        packet_write_fmt(1, "ACK %s\n", last_hex);
@@ -490,7 +490,7 @@ static int get_common_commits(struct upload_pack_data *data,
                }
                if (!strcmp(reader->line, "done")) {
                        if (data->have_obj.nr > 0) {
-                               if (multi_ack)
+                               if (data->multi_ack)
                                        packet_write_fmt(1, "ACK %s\n", last_hex);
                                return 0;
                        }
@@ -958,9 +958,9 @@ static void receive_needs(struct upload_pack_data *data,
                if (parse_feature_request(features, "deepen-relative"))
                        data->deepen_relative = 1;
                if (parse_feature_request(features, "multi_ack_detailed"))
-                       multi_ack = 2;
+                       data->multi_ack = 2;
                else if (parse_feature_request(features, "multi_ack"))
-                       multi_ack = 1;
+                       data->multi_ack = 1;
                if (parse_feature_request(features, "no-done"))
                        data->no_done = 1;
                if (parse_feature_request(features, "thin-pack"))