]> git.ipfire.org Git - thirdparty/git.git/blobdiff - connect.c
Ignore funny refname sent from remote
[thirdparty/git.git] / connect.c
index 247f02fb4cb3b3f96017c45427dfafd077692ebd..f71eba8af8b994fee8a928fc0a18ce08a9fd3506 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -10,7 +10,8 @@
 /*
  * Read all the refs from the other end
  */
-struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match)
+struct ref **get_remote_heads(int in, struct ref **list,
+                             int nr_match, char **match, int ignore_funny)
 {
        *list = NULL;
        for (;;) {
@@ -29,6 +30,11 @@ struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **ma
                if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
                        die("protocol error: expected sha/ref, got '%s'", buffer);
                name = buffer + 41;
+
+               if (ignore_funny && 45 < len && !memcmp(name, "refs/", 5) &&
+                   check_ref_format(name + 5))
+                       continue;
+
                if (nr_match && !path_match(name, nr_match, match))
                        continue;
                ref = xcalloc(1, sizeof(*ref) + len - 40);