From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 3/6 (v2)] connect.c::read_extra_info(): find where HEAD points at
Date: Mon, 1 Dec 2008 06:12:52 -0800 [thread overview]
Message-ID: <1228140775-29212-4-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1228140775-29212-3-git-send-email-gitster@pobox.com>
This actually implements the protocol extension to receive the HEAD symref
information that is hidden after the server capabilities list. Nobody
uses the information yet, though.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
connect.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/connect.c b/connect.c
index 114d691..aa4757a 100644
--- a/connect.c
+++ b/connect.c
@@ -53,7 +53,7 @@ static void add_extra_have(struct extra_have_objects *extra, unsigned char *sha1
* NUL". "len" is the remaining number of bytes. The caller knows
* that the original packet contains more information than that.
*/
-static void read_extra_info(char *line, int len)
+static void read_extra_info(char *line, int len, char **hpa)
{
/*
* The first such "extra" piece of information is the list of
@@ -64,6 +64,20 @@ static void read_extra_info(char *line, int len)
free(server_capabilities);
server_capabilities = xmalloc(infolen);
memcpy(server_capabilities, line, infolen);
+ if (infolen == len)
+ return;
+ /*
+ * The uploader can optionally tell us where the HEAD pointer
+ * points at after that.
+ */
+ line += infolen;
+ len -= infolen;
+
+ infolen = strlen(line) + 1;
+
+ free(*hpa);
+ *hpa = xmalloc(infolen);
+ memcpy(*hpa, line, infolen);
}
/*
@@ -74,6 +88,9 @@ struct ref **get_remote_heads(int in, struct ref **list,
unsigned int flags,
struct extra_have_objects *extra_have)
{
+ struct ref **ref_list = list;
+ char *head_points_at = NULL;
+
*list = NULL;
for (;;) {
struct ref *ref;
@@ -97,7 +114,8 @@ struct ref **get_remote_heads(int in, struct ref **list,
name_len = strlen(name);
if (len != name_len + 41)
- read_extra_info(name + name_len + 1, len - (name_len + 41));
+ read_extra_info(name + name_len + 1, len - (name_len + 41),
+ &head_points_at);
if (extra_have &&
name_len == 5 && !memcmp(".have", name, 5)) {
@@ -114,6 +132,11 @@ struct ref **get_remote_heads(int in, struct ref **list,
*list = ref;
list = &ref->next;
}
+ if (head_points_at) {
+ struct ref *head = find_ref_by_name(*ref_list, "HEAD");
+ if (head)
+ head->symref = head_points_at;
+ }
return list;
}
--
1.6.0.4.864.g0f47a
next prev parent reply other threads:[~2008-12-01 14:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-01 14:12 [PATCH 0/6 (v2)] Detecting HEAD more reliably while cloning Junio C Hamano
2008-12-01 14:12 ` [PATCH 1/6 (v2)] get_remote_heads(): refactor code to read "server capabilities" Junio C Hamano
2008-12-01 14:12 ` [PATCH 2/6 (v2)] connect.c::read_extra_info(): prepare to receive more than server capabilities Junio C Hamano
2008-12-01 14:12 ` Junio C Hamano [this message]
2008-12-01 14:12 ` [PATCH 4/6 (v2)] clone: find the current branch more explicitly Junio C Hamano
2008-12-01 14:12 ` [PATCH 5/6 (v2)] upload-pack: send the HEAD information Junio C Hamano
2008-12-01 14:12 ` [PATCH 6/6 (v2)] clone: test the new HEAD detection logic Junio C Hamano
2008-12-01 15:40 ` [PATCH 5/6 (v2)] upload-pack: send the HEAD information Jakub Narebski
2008-12-01 16:20 ` Shawn O. Pearce
2008-12-01 19:54 ` Junio C Hamano
2008-12-01 17:44 ` Jeff King
2008-12-02 1:31 ` Junio C Hamano
2008-12-02 1:59 ` Jeff King
2008-12-02 2:20 ` Junio C Hamano
2008-12-02 2:36 ` Jeff King
2008-12-01 15:52 ` [PATCH 0/6 (v2)] Detecting HEAD more reliably while cloning Johannes Sixt
2008-12-02 1:33 ` Junio C Hamano
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=1228140775-29212-4-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--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 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).