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

[PATCH v2 4/6] receive-pack: Refactor how capabilities are shown to the client

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

Moving capability advertisement into the packet_write call itself makes it easier to add additional capabilities to the list, be it optional by configuration, or always present in the protocol.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-receive-pack.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index 78c0e69..325ec6e 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -31,7 +31,7 @@ static int prefer_ofs_delta = 1;
 static int auto_update_server_info;
 static int auto_gc = 1;
 static const char *head_name;
-static char *capabilities_to_send;
+static int sent_capabilities;
 
 static enum deny_action parse_deny_action(const char *var, const char *value)
 {
@@ -105,19 +105,21 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
 
 static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
 {
-	if (!capabilities_to_send)
+	if (sent_capabilities)
 		packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
 	else
-		packet_write(1, "%s %s%c%s\n",
-			     sha1_to_hex(sha1), path, 0, capabilities_to_send);
-	capabilities_to_send = NULL;
+		packet_write(1, "%s %s%c%s%s\n",
+			     sha1_to_hex(sha1), path, 0,
+			     " report-status delete-refs",
+			     prefer_ofs_delta ? " ofs-delta" : "");
+	sent_capabilities = 1;
 	return 0;
 }
 
 static void write_head_info(void)
 {
 	for_each_ref(show_ref, NULL);
-	if (capabilities_to_send)
+	if (!sent_capabilities)
 		show_ref("capabilities^{}", null_sha1, 0, NULL);
 
 }
@@ -670,10 +672,6 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 	else if (0 <= receive_unpack_limit)
 		unpack_limit = receive_unpack_limit;
 
-	capabilities_to_send = (prefer_ofs_delta) ?
-		" report-status delete-refs ofs-delta " :
-		" report-status delete-refs ";
-
 	if (advertise_refs || !stateless_rpc) {
 		add_alternate_refs();
 		write_head_info();
-- 
1.7.0.rc1.199.g9253ab
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 5 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.