Skip to content

Commit eb7b974

Browse files
bmwillgitster
authored andcommitted
send-pack: send push options correctly in stateless-rpc case
"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 <[email protected]> Signed-off-by: Brandon Williams <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 438fc68 commit eb7b974

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

send-pack.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,14 @@ int send_pack(struct send_pack_args *args,
514514
}
515515
}
516516

517+
if (use_push_options) {
518+
struct string_list_item *item;
519+
520+
packet_buf_flush(&req_buf);
521+
for_each_string_list_item(item, args->push_options)
522+
packet_buf_write(&req_buf, "%s", item->string);
523+
}
524+
517525
if (args->stateless_rpc) {
518526
if (!args->dry_run && (cmds_sent || is_repository_shallow())) {
519527
packet_buf_flush(&req_buf);
@@ -526,18 +534,6 @@ int send_pack(struct send_pack_args *args,
526534
strbuf_release(&req_buf);
527535
strbuf_release(&cap_buf);
528536

529-
if (use_push_options) {
530-
struct string_list_item *item;
531-
struct strbuf sb = STRBUF_INIT;
532-
533-
for_each_string_list_item(item, args->push_options)
534-
packet_buf_write(&sb, "%s", item->string);
535-
536-
write_or_die(out, sb.buf, sb.len);
537-
packet_flush(out);
538-
strbuf_release(&sb);
539-
}
540-
541537
if (use_sideband && cmds_sent) {
542538
memset(&demux, 0, sizeof(demux));
543539
demux.proc = sideband_demux;

0 commit comments

Comments
 (0)