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

[PATCH 5/7] Refactor send-pack/receive-pack capability handshake for extension

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 30, 2008, 06:22 UTC
Message-ID
<20080130062209.GE15838@spearce.org>

This refactors the capability selection in send-pack to be more like how fetch-pack handles the transmission to the remote peer, so we can easily add additional capability strings to the push protocol as needed.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-send-pack.c |   17 ++++++++---------
 receive-pack.c      |    3 ++-
 2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 8afb1d0..63fbcd2 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -378,10 +378,10 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 {
 	struct ref *ref;
 	int new_refs;
-	int ask_for_status_report = 0;
 	int allow_deleting_refs = 0;
 	int expect_status_report = 0;
 	int flags = MATCH_REFS_NONE;
+	int pushing = 0;
 	int ret;
 
 	if (args.send_all)
@@ -395,7 +395,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 
 	/* Does the other end support the reporting? */
 	if (server_supports("report-status"))
-		ask_for_status_report = 1;
+		expect_status_report = 1;
 	if (server_supports("delete-refs"))
 		allow_deleting_refs = 1;
 
@@ -477,18 +477,17 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 			char *old_hex = sha1_to_hex(ref->old_sha1);
 			char *new_hex = sha1_to_hex(ref->new_sha1);
 
-			if (ask_for_status_report) {
+			if (!pushing)
 				packet_write(out, "%s %s %s%c%s",
 					old_hex, new_hex, ref->name, 0,
-					"report-status");
-				ask_for_status_report = 0;
-				expect_status_report = 1;
-			}
+					(expect_status_report ? " report-status" : "")
+				);
 			else
 				packet_write(out, "%s %s %s",
 					old_hex, new_hex, ref->name);
+			pushing++;
 		}
-		ref->status = expect_status_report ?
+		ref->status = pushing && expect_status_report ?
 			REF_STATUS_EXPECTING_REPORT :
 			REF_STATUS_OK;
 	}
@@ -502,7 +501,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 	}
 	close(out);
 
-	if (expect_status_report)
+	if (pushing && expect_status_report)
 		ret = receive_status(in, remote_refs);
 	else
 		ret = 0;
diff --git a/receive-pack.c b/receive-pack.c
index 3267495..7380395 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -318,7 +318,8 @@ static void read_head_info(void)
 		refname = line + 82;
 		reflen = strlen(refname);
 		if (reflen + 82 < len) {
-			if (strstr(refname + reflen + 1, "report-status"))
+			const char *reqcap = refname + reflen + 1;
+			if (strstr(reqcap, "report-status"))
 				report_status = 1;
 		}
 		cmd = xmalloc(sizeof(struct command) + len - 80);
-- 
1.5.4.rc5.1126.g6ba14
Message 1 of 1 in “Refactor send-pack/receive-pack capability handshake for extension”
  1. 5/7 Refactor send-pack/receive-pack capability handshake for extensionShawn O. Pearce, Jan 30, 2008

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.