summaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2020-06-04 17:54:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-06-04 17:58:26 (GMT)
commit53d69506c1108f5d4f7ac2fccd871946ff012071 (patch)
tree797c7c3610c635fb7a118cfe46a8e07ecb8cf6a0 /upload-pack.c
parent59a902612ab2cdea2a30882e90680a1e7618f823 (diff)
downloadgit-53d69506c1108f5d4f7ac2fccd871946ff012071.zip
git-53d69506c1108f5d4f7ac2fccd871946ff012071.tar.gz
git-53d69506c1108f5d4f7ac2fccd871946ff012071.tar.bz2
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>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 6226387..f8611a5 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -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"))