From: Jonathan Tan <jonathantanmy@google.com>
To: git@vger.kernel.org
Cc: Jonathan Tan <jonathantanmy@google.com>,
gitster@pobox.com, jrnieder@gmail.com
Subject: [PATCH v2 1/3] fetch-pack: return enum from process_acks()
Date: Mon, 27 Apr 2020 17:01:08 -0700 [thread overview]
Message-ID: <f0cfbc03c27658e54a73c46570c5153961ed85b6.1588031728.git.jonathantanmy@google.com> (raw)
In-Reply-To: <cover.1588031728.git.jonathantanmy@google.com>
process_acks() returns 0, 1, or 2, depending on whether "ready" was
received and if not, whether at least one commit was found to be common.
Replace these magic numbers with a documented enum.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
fetch-pack.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/fetch-pack.c b/fetch-pack.c
index 0b07b3ee73..45547a621e 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1268,9 +1268,29 @@ static int process_section_header(struct packet_reader *reader,
return ret;
}
-static int process_acks(struct fetch_negotiator *negotiator,
- struct packet_reader *reader,
- struct oidset *common)
+enum common_found {
+ /*
+ * No commit was found to be possessed by both the client and the
+ * server, and "ready" was not received.
+ */
+ NO_COMMON_FOUND,
+
+ /*
+ * At least one commit was found to be possessed by both the client and
+ * the server, and "ready" was not received.
+ */
+ COMMON_FOUND,
+
+ /*
+ * "ready" was received, indicating that the server is ready to send
+ * the packfile without any further negotiation.
+ */
+ READY
+};
+
+static enum common_found process_acks(struct fetch_negotiator *negotiator,
+ struct packet_reader *reader,
+ struct oidset *common)
{
/* received */
int received_ready = 0;
@@ -1320,7 +1340,8 @@ static int process_acks(struct fetch_negotiator *negotiator,
die(_("expected no other sections to be sent after no 'ready'"));
/* return 0 if no common, 1 if there are common, or 2 if ready */
- return received_ready ? 2 : (received_ack ? 1 : 0);
+ return received_ready ? READY :
+ (received_ack ? COMMON_FOUND : NO_COMMON_FOUND);
}
static void receive_shallow_info(struct fetch_pack_args *args,
@@ -1508,13 +1529,13 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
case FETCH_PROCESS_ACKS:
/* Process ACKs/NAKs */
switch (process_acks(negotiator, &reader, &common)) {
- case 2:
+ case READY:
state = FETCH_GET_PACK;
break;
- case 1:
+ case COMMON_FOUND:
in_vain = 0;
/* fallthrough */
- default:
+ case NO_COMMON_FOUND:
state = FETCH_SEND_REQUEST;
break;
}
--
2.26.2.303.gf8c07b1a785-goog
next prev parent reply other threads:[~2020-04-28 0:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-25 0:56 [PATCH 0/2] Protocol v2 in_vain fixes Jonathan Tan
2020-04-25 0:56 ` [PATCH 1/2] fetch-pack: in protocol v2, in_vain only after ACK Jonathan Tan
2020-04-25 5:08 ` Junio C Hamano
2020-04-26 0:28 ` Jonathan Nieder
2020-04-27 17:27 ` Jonathan Tan
2020-04-27 22:16 ` Junio C Hamano
2020-04-25 0:56 ` [PATCH 2/2] fetch-pack: in protocol v2, reset in_vain upon ACK Jonathan Tan
2020-04-26 1:10 ` Jonathan Nieder
2020-04-27 17:28 ` Jonathan Tan
2020-04-28 0:01 ` [PATCH v2 0/3] Protocol v2 in_vain fixes Jonathan Tan
2020-04-28 0:01 ` Jonathan Tan [this message]
2020-04-28 0:53 ` [PATCH v2 1/3] fetch-pack: return enum from process_acks() Jonathan Nieder
2020-04-28 16:54 ` Junio C Hamano
2020-04-28 18:00 ` Michal Suchánek
2020-04-28 19:17 ` Junio C Hamano
2020-04-28 0:01 ` [PATCH v2 2/3] fetch-pack: in protocol v2, in_vain only after ACK Jonathan Tan
2020-04-28 0:54 ` Jonathan Nieder
2020-05-06 21:08 ` Johannes Schindelin
2020-05-06 22:07 ` [PATCH] t5500: count objects through stderr, not trace Jonathan Tan
2020-05-06 22:28 ` Junio C Hamano
2020-05-06 22:40 ` Junio C Hamano
2020-05-07 14:35 ` Johannes Schindelin
2020-10-13 14:45 ` Johannes Schindelin
2020-04-28 0:01 ` [PATCH v2 3/3] fetch-pack: in protocol v2, reset in_vain upon ACK Jonathan Tan
2020-04-28 0:55 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0cfbc03c27658e54a73c46570c5153961ed85b6.1588031728.git.jonathantanmy@google.com \
--to=jonathantanmy@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).