From 5b204b7df3ed7e97040d40db9d7c31a0a645af15 Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Wed, 22 May 2019 13:08:22 -0700 Subject: [PATCH] fetch-pack: send server options after command Currently, if any server options are specified during a protocol v2 fetch, server options will be sent before "command=fetch". Write server options to the request buffer in send_fetch_request() so that the components of the request are sent in the correct order. The protocol documentation states that the command must come first. The Git server implementation in serve.c (see process_request() in that file) tolerates any order of command and capability, which is perhaps why we haven't noticed this. This was noticed when testing against a JGit server implementation, which follows the documentation in this regard. Signed-off-by: Jonathan Tan Acked-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- fetch-pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch-pack.c b/fetch-pack.c index 812be15d7e..46651b16bc 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1111,7 +1111,7 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out, server_supports_v2("server-option", 1)) { int i; for (i = 0; i < args->server_options->nr; i++) - packet_write_fmt(fd_out, "server-option=%s", + packet_buf_write(&req_buf, "server-option=%s", args->server_options->items[i].string); } -- 2.47.1