receive-pack: Wrap status reports inside side-band-64k
If the client requests the side-band-64k protocol capability we now wrap the status report data inside of packets sent to band #1. This permits us to later send additional progress or informational messages down band #2. If side-band-64k was enabled, we always send a final flush packet to let the client know we are done transmitting. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Feb 5, 2010 at 12:57 UTC
38a81b4e82ebf57549f2fa082b329c36dffc0b18
1 file changed
+22
-8
builtin-receive-pack.c
+22
-8
@@ -2,6 +2,7 @@
2
#include "pack.h"
3
#include "refs.h"
4
#include "pkt-line.h"
5
+#include "sideband.h"
6
#include "run-command.h"
7
#include "exec_cmd.h"
8
#include "commit.h"
@@ -27,6 +28,7 @@ static int receive_unpack_limit = -1;
28
static int transfer_unpack_limit = -1;
29
static int unpack_limit = 100;
30
static int report_status;
31
+static int use_sideband;
32
static int prefer_ofs_delta = 1;
33
static int auto_update_server_info;
34
static int auto_gc = 1;
@@ -110,7 +112,7 @@ static int show_ref(const char *path, const unsigned char *sha1, int flag, void
112
else
113
packet_write(1, "%s %s%c%s%s\n",
114
sha1_to_hex(sha1), path, 0,
113
- " report-status delete-refs",
115
+ " report-status delete-refs side-band-64k",
116
prefer_ofs_delta ? " ofs-delta" : "");
117
sent_capabilities = 1;
118
return 0;
@@ -466,6 +468,8 @@ static void read_head_info(void)
468
if (reflen + 82 < len) {
469
if (strstr(refname + reflen + 1, "report-status"))
470
report_status = 1;
471
+ if (strstr(refname + reflen + 1, "side-band-64k"))
472
+ use_sideband = LARGE_PACKET_MAX;
473
}
474
cmd = xmalloc(sizeof(struct command) + len - 80);
475
hashcpy(cmd->old_sha1, old_sha1);
@@ -565,17 +569,25 @@ static const char *unpack(void)
569
static void report(const char *unpack_status)
570
{
571
struct command *cmd;
568
- packet_write(1, "unpack %s\n",
569
- unpack_status ? unpack_status : "ok");
572
+ struct strbuf buf = STRBUF_INIT;
573
+
574
+ packet_buf_write(&buf, "unpack %s\n",
575
+ unpack_status ? unpack_status : "ok");
576
for (cmd = commands; cmd; cmd = cmd->next) {
577
if (!cmd->error_string)
572
- packet_write(1, "ok %s\n",
573
- cmd->ref_name);
578
+ packet_buf_write(&buf, "ok %s\n",
579
+ cmd->ref_name);
580
else
575
- packet_write(1, "ng %s %s\n",
576
- cmd->ref_name, cmd->error_string);
581
+ packet_buf_write(&buf, "ng %s %s\n",
582
+ cmd->ref_name, cmd->error_string);
583
}
578
- packet_flush(1);
584
+ packet_buf_flush(&buf);
585
+
586
+ if (use_sideband)
587
+ send_sideband(1, 1, buf.buf, buf.len, use_sideband);
588
+ else
589
+ safe_write(1, buf.buf, buf.len);
590
+ strbuf_release(&buf);
591
}
592
593
static int delete_only(struct command *cmd)
@@ -705,5 +717,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
717
if (auto_update_server_info)
718
update_server_info(0);
719
}
720
+ if (use_sideband)
721
+ packet_flush(1);
722
return 0;
723
}