git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/2] send-pack: send push options correctly in stateless-rpc case

From
BWBrandon Williams <bmwill@google.com>
Date
Mar 22, 2017, 22:21 UTC
Message-ID
<20170322222200.103204-2-bmwill@google.com>
In-Reply-To
<20170322222200.103204-1-bmwill@google.com>

"git send-pack --stateless-rpc" puts each request in a sequence of pkt-lines followed by a flush-pkt. The push option code forgot about this and sends push options and their terminating delimiter as ordinary pkt-lines that get their length header stripped off by remote-curl before being sent to the server.

The result is multiple malformed requests, which the server rejects.

Fortunately send-pack --stateless-rpc already is aware of this "pkt-line within pkt-line" framing for the update commands that precede push options. Handle push options the same way.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
---
 send-pack.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/send-pack.c b/send-pack.c
index d2d2a49a0..66e652f7e 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -532,6 +532,14 @@ int send_pack(struct send_pack_args *args,
 		}
 	}
 
+	if (use_push_options) {
+		struct string_list_item *item;
+
+		packet_buf_flush(&req_buf);
+		for_each_string_list_item(item, args->push_options)
+			packet_buf_write(&req_buf, "%s", item->string);
+	}
+
 	if (args->stateless_rpc) {
 		if (!args->dry_run && (cmds_sent || is_repository_shallow())) {
 			packet_buf_flush(&req_buf);
@@ -544,18 +552,6 @@ int send_pack(struct send_pack_args *args,
 	strbuf_release(&req_buf);
 	strbuf_release(&cap_buf);
 
-	if (use_push_options) {
-		struct string_list_item *item;
-		struct strbuf sb = STRBUF_INIT;
-
-		for_each_string_list_item(item, args->push_options)
-			packet_buf_write(&sb, "%s", item->string);
-
-		write_or_die(out, sb.buf, sb.len);
-		packet_flush(out);
-		strbuf_release(&sb);
-	}
-
 	if (use_sideband && cmds_sent) {
 		memset(&demux, 0, sizeof(demux));
 		demux.proc = sideband_demux;
-- 
2.12.1.500.gab5fba24ee-goog
Previous: Brandon WilliamsNext: Brandon Williams
Message 13 of 15 in “push options across http”
  1. 0/2 push options across httpBrandon Williams, Mar 22, 2017
  2. 2/2 remote-curl: allow push optionsBrandon Williams, Mar 22, 2017
  3. Junio C HamanoMar 22, 2017
  4. Brandon WilliamsMar 22, 2017
  5. Jonathan NiederMar 22, 2017
  6. Brandon WilliamsMar 22, 2017
  7. 1/2 send-pack: send push options correctly in stateless-rpc caseBrandon Williams, Mar 22, 2017
  8. Jonathan NiederMar 22, 2017
  9. Brandon WilliamsMar 22, 2017
  10. Junio C HamanoMar 22, 2017
  11. Stefan BellerMar 22, 2017
  12. 0/2 push options across httpBrandon Williams, Mar 22, 2017
  13. 1/2 send-pack: send push options correctly in stateless-rpc caseBrandon Williams, Mar 22, 2017
  14. 2/2 remote-curl: allow push optionsBrandon Williams, Mar 22, 2017
  15. Jonathan NiederMar 22, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.