]> git.ipfire.org Git - thirdparty/git.git/commitdiff
send-pack: send push options correctly in stateless-rpc case
authorBrandon Williams <bmwill@google.com>
Wed, 22 Mar 2017 22:21:59 +0000 (15:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Mar 2017 22:41:15 +0000 (15:41 -0700)
"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>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
send-pack.c

index 6195b43e9abacf346f52b6bbb758c9ca7b617d4e..56cc5c3a746224bc3dc54880363b9625d0faed91 100644 (file)
@@ -514,6 +514,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);
@@ -526,18 +534,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;