[PATCH v3 07/12] serve.c: move version line to advertise_capabilities()
To
git@vger.kernel.org
Cc
Junio C Hamano
Jonathan Tan
Josh Steadmon
Bruno Albuquerque
Jeff King
Eric Sunshine
Han-Wen Nienhuys
Ævar Arnfjörð Bjarmason
From
Ævar Arnfjörð Bjarmason
See Also
Prev Ref 1
Date
2021-07-21 23:40:08 UTC
The advertise_capabilities() is only called from serve() and we always
emit this version line before it, it makes more sense to consider the
capabilities part of a "header" that has the version, so let's move
the writing of the version there.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 serve.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/serve.c b/serve.c
index 3c7c9329a14..10209ab237d 100644
--- a/serve.c
+++ b/serve.c
@@ -168,6 +168,9 @@ static void advertise_capabilities(void)
 	struct strbuf value = STRBUF_INIT;
 	int i;
 
+	/* serve by default supports v2 */
+	packet_write_fmt(1, "version 2\n");
+
 	for (i = 0; i < ARRAY_SIZE(capabilities); i++) {
 		struct protocol_capability *c = &capabilities[i];
 
@@ -360,9 +363,6 @@ static int process_request(void)
 void serve(struct serve_options *options)
 {
 	if (options->advertise_capabilities || !options->stateless_rpc) {
-		/* serve by default supports v2 */
-		packet_write_fmt(1, "version 2\n");
-
 		advertise_capabilities();
 		/*
 		 * If only the list of capabilities was requested exit
-- 
2.32.0.955.ge7c5360f7e7