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

[PATCH v2 5/6] receive-pack: Wrap status reports inside side-band-64k

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 5, 2010, 20:57 UTC
Message-ID
<1265403462-20572-6-git-send-email-spearce@spearce.org>
In-Reply-To
<1265403462-20572-1-git-send-email-spearce@spearce.org>

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>
---
 builtin-receive-pack.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index 325ec6e..ff3f117 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -2,6 +2,7 @@
 #include "pack.h"
 #include "refs.h"
 #include "pkt-line.h"
+#include "sideband.h"
 #include "run-command.h"
 #include "exec_cmd.h"
 #include "commit.h"
@@ -27,6 +28,7 @@ static int receive_unpack_limit = -1;
 static int transfer_unpack_limit = -1;
 static int unpack_limit = 100;
 static int report_status;
+static int use_sideband;
 static int prefer_ofs_delta = 1;
 static int auto_update_server_info;
 static int auto_gc = 1;
@@ -110,7 +112,7 @@ static int show_ref(const char *path, const unsigned char *sha1, int flag, void
 	else
 		packet_write(1, "%s %s%c%s%s\n",
 			     sha1_to_hex(sha1), path, 0,
-			     " report-status delete-refs",
+			     " report-status delete-refs side-band-64k",
 			     prefer_ofs_delta ? " ofs-delta" : "");
 	sent_capabilities = 1;
 	return 0;
@@ -466,6 +468,8 @@ static void read_head_info(void)
 		if (reflen + 82 < len) {
 			if (strstr(refname + reflen + 1, "report-status"))
 				report_status = 1;
+			if (strstr(refname + reflen + 1, "side-band-64k"))
+				use_sideband = LARGE_PACKET_MAX;
 		}
 		cmd = xmalloc(sizeof(struct command) + len - 80);
 		hashcpy(cmd->old_sha1, old_sha1);
@@ -565,17 +569,25 @@ static const char *unpack(void)
 static void report(const char *unpack_status)
 {
 	struct command *cmd;
-	packet_write(1, "unpack %s\n",
-		     unpack_status ? unpack_status : "ok");
+	struct strbuf buf = STRBUF_INIT;
+
+	packet_buf_write(&buf, "unpack %s\n",
+			 unpack_status ? unpack_status : "ok");
 	for (cmd = commands; cmd; cmd = cmd->next) {
 		if (!cmd->error_string)
-			packet_write(1, "ok %s\n",
-				     cmd->ref_name);
+			packet_buf_write(&buf, "ok %s\n",
+					 cmd->ref_name);
 		else
-			packet_write(1, "ng %s %s\n",
-				     cmd->ref_name, cmd->error_string);
+			packet_buf_write(&buf, "ng %s %s\n",
+					 cmd->ref_name, cmd->error_string);
 	}
-	packet_flush(1);
+	packet_buf_flush(&buf);
+
+	if (use_sideband)
+		send_sideband(1, 1, buf.buf, buf.len, use_sideband);
+	else
+		safe_write(1, buf.buf, buf.len);
+	strbuf_release(&buf);
 }
 
 static int delete_only(struct command *cmd)
@@ -705,5 +717,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 		if (auto_update_server_info)
 			update_server_info(0);
 	}
+	if (use_sideband)
+		packet_flush(1);
 	return 0;
 }
-- 
1.7.0.rc1.199.g9253ab
Previous: Shawn O. PearceNext: Junio C Hamano
Message 6 of 14 in “receive-pack hooks over sideband”
  1. 0/6 receive-pack hooks over sidebandShawn O. Pearce, Feb 5, 2010
  2. 1/6 run-command: Allow stderr to be a caller supplied pipeShawn O. Pearce, Feb 5, 2010
  3. 2/6 run-command: support custom fd-set in asyncShawn O. Pearce, Feb 5, 2010
  4. 3/6 send-pack: demultiplex a sideband stream with status dataShawn O. Pearce, Feb 5, 2010
  5. 4/6 receive-pack: Refactor how capabilities are shown to the clientShawn O. Pearce, Feb 5, 2010
  6. 5/6 receive-pack: Wrap status reports inside side-band-64kShawn O. Pearce, Feb 5, 2010
  7. Junio C HamanoFeb 5, 2010
  8. Shawn O. PearceFeb 5, 2010
  9. Junio C HamanoFeb 5, 2010
  10. 6/6 receive-pack: Send hook output over side band #2Shawn O. Pearce, Feb 5, 2010
  11. Larry D'AnnaFeb 9, 2010
  12. Shawn O. PearceFeb 9, 2010
  13. Larry D'AnnaFeb 9, 2010
  14. Larry D'AnnaFeb 9, 2010

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.