git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 5/7] Refactor send-pack/receive-pack capability handshake for extension
Date: Wed, 30 Jan 2008 01:22:09 -0500	[thread overview]
Message-ID: <20080130062209.GE15838@spearce.org> (raw)

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

                 reply	other threads:[~2008-01-30  6:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080130062209.GE15838@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).