Skip to contentSkip to conversation

fetch-pack: send server options after command

PATCH In review Jonathan Tan 3 participants 3 messages May 22, 2019 – May 28, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fetch-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fetch-pack.c +1 -1
index 3f24d0c8a6..1c10f54e78 100644
@@ -1115,7 +1115,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);
 	}
 
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Jonathan Tan

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.

Quoted 4 lines
---
 fetch-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Oh, dear. Thanks for fixing it.

6e98305985 (clone: send server options when using protocol v2, 2019-04-12) is part of release candidates, but it looks like we caught this in time to get the fix in before the release.

Should we add an interop test for this to t/interop/?

Thanks,
Jonathan

#2 lore raw
Quoted 14 lines · Jonathan Nieder
Quoted 12 lines · Jonathan Tan

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.

Quoted 8 lines
Quoted 4 lines
---
 fetch-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Oh, dear. Thanks for fixing it.

Yeah, looks good. Thanks.

Quoted 9 lines

6e98305985 (clone: send server options when using protocol v2, 2019-04-12) is part of release candidates, but it looks like we caught this in time to get the fix in before the release.

Should we add an interop test for this to t/interop/?

Thanks,
Jonathan