{"thread":{"id":"2103","subject":"[PATCH] Ignore funny refname sent from remote","startedAt":"2005-10-14T06:03:43Z","lastAt":"2005-10-14T06:03:43Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10093","messageId":"7virw0ws74.fsf@assigned-by-dhcp.cox.net","threadId":"2103","inReplyTo":null,"subject":"[PATCH] Ignore funny refname sent from remote","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-14T06:03:43Z","receivedAt":"2005-10-14T06:03:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This allows the remote side (most notably, upload-pack) to show\nadditional information without affecting the downloader.  Peek-remote\ndoes not ignore them -- this is to make it useful for Pasky's\nautomatic tag following.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * This is a preparation for the next one, which starts sending\n   out extra \"refs\" from upload-pack.  Normal client side should\n   not get affected by those extra info.\n\n cache.h       |    2 +-\n clone-pack.c  |    2 +-\n connect.c     |    8 +++++++-\n fetch-pack.c  |    2 +-\n peek-remote.c |    2 +-\n send-pack.c   |    2 +-\n 6 files changed, 12 insertions(+), 6 deletions(-)\n\napplies-to: c0f2aa6e25a9291830ddd86acfc569fd33077ec6\n60b2e010ba8dd4c24fe6ef7bfc1ee3185ac2cf52\ndiff --git a/cache.h b/cache.h\nindex 3286582..8aa63cc 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -339,7 +339,7 @@ extern int path_match(const char *path, \n extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,\n \t\t      int nr_refspec, char **refspec, int all);\n extern int get_ack(int fd, unsigned char *result_sha1);\n-extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match);\n+extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, int ignore_funny);\n \n extern struct packed_git *parse_pack_index(unsigned char *sha1);\n extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,\ndiff --git a/clone-pack.c b/clone-pack.c\nindex 0ea7e7f..f9b263a 100644\n--- a/clone-pack.c\n+++ b/clone-pack.c\n@@ -287,7 +287,7 @@ static int clone_pack(int fd[2], int nr_\n \tstruct ref *refs;\n \tint status;\n \n-\tget_remote_heads(fd[0], &refs, nr_match, match);\n+\tget_remote_heads(fd[0], &refs, nr_match, match, 1);\n \tif (!refs) {\n \t\tpacket_flush(fd[1]);\n \t\tdie(\"no matching remote head\");\ndiff --git a/connect.c b/connect.c\nindex b157cf1..b6732f6 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -10,7 +10,8 @@\n /*\n  * Read all the refs from the other end\n  */\n-struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match)\n+struct ref **get_remote_heads(int in, struct ref **list,\n+\t\t\t      int nr_match, char **match, int ignore_funny)\n {\n \t*list = NULL;\n \tfor (;;) {\n@@ -29,6 +30,11 @@ struct ref **get_remote_heads(int in, st\n \t\tif (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')\n \t\t\tdie(\"protocol error: expected sha/ref, got '%s'\", buffer);\n \t\tname = buffer + 41;\n+\n+\t\tif (ignore_funny && 45 < len && !memcmp(name, \"refs/\", 5) &&\n+\t\t    check_ref_format(name + 5))\n+\t\t\tcontinue;\n+\n \t\tif (nr_match && !path_match(name, nr_match, match))\n \t\t\tcontinue;\n \t\tref = xcalloc(1, sizeof(*ref) + len - 40);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 582f967..953c0cf 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -81,7 +81,7 @@ static int fetch_pack(int fd[2], int nr_\n \tint status;\n \tpid_t pid;\n \n-\tget_remote_heads(fd[0], &ref, nr_match, match);\n+\tget_remote_heads(fd[0], &ref, nr_match, match, 1);\n \tif (!ref) {\n \t\tpacket_flush(fd[1]);\n \t\tdie(\"no matching remote head\");\ndiff --git a/peek-remote.c b/peek-remote.c\nindex 4b1d0d5..ee49bf3 100644\n--- a/peek-remote.c\n+++ b/peek-remote.c\n@@ -11,7 +11,7 @@ static int peek_remote(int fd[2])\n {\n \tstruct ref *ref;\n \n-\tget_remote_heads(fd[0], &ref, 0, NULL);\n+\tget_remote_heads(fd[0], &ref, 0, NULL, 0);\n \tpacket_flush(fd[1]);\n \n \twhile (ref) {\ndiff --git a/send-pack.c b/send-pack.c\nindex 55d8ff7..9f9a6e7 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -181,7 +181,7 @@ static int send_pack(int in, int out, in\n \tint new_refs;\n \n \t/* No funny business with the matcher */\n-\tremote_tail = get_remote_heads(in, &remote_refs, 0, NULL);\n+\tremote_tail = get_remote_heads(in, &remote_refs, 0, NULL, 1);\n \tget_local_heads();\n \n \t/* match them up */\n---\n@@GIT_VERSION@@\n"}]}