serve.c: move version line to advertise_capabilities()

The advertise_capabilities() is only called from serve() and we always
emit this version line before it. In a subsequent commit I'll make
builtin/upload-pack.c sometimes call advertise_capabilities()
directly, so it'll make sense to have this line emitted by
advertise_capabilities(), not serve() itself.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2021-08-05 03:25:40 +02:00 committed by Junio C Hamano
parent eea7f7a977
commit 5befe8a1f1

View File

@ -112,6 +112,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];
@ -304,9 +307,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