From: "Shawn O. Pearce" <spearce@spearce.org>
To: git@vger.kernel.org
Subject: [PATCH 4/6] Refactor send-pack/receive-pack capability handshake for extension
Date: Thu, 14 Feb 2008 01:22:49 -0500 [thread overview]
Message-ID: <20080214062249.GD30516@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.1.1309.g833c2
reply other threads:[~2008-02-14 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=20080214062249.GD30516@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.