[PATCH 4/6] Refactor send-pack/receive-pack capability handshake for extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 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.1.1309.g833c2

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux