-struct ref {
- struct ref *next;
- unsigned char sha1[20];
- char name[0];
-};
-
-static struct ref *get_remote_refs(int fd, int nr_match, char **match)
-{
- struct ref *ref_list = NULL, **next_ref = &ref_list;
-
- for (;;) {
- static char line[1000];
- unsigned char sha1[20];
- struct ref *ref;
- char *refname;
- int len;
-
- len = packet_read_line(fd, line, sizeof(line));
- if (!len)
- break;
- if (line[len-1] == '\n')
- line[--len] = 0;
- if (len < 42 || get_sha1_hex(line, sha1))
- die("git-fetch-pack: protocol error - expected ref descriptor, got '%s¤'", line);
- refname = line+41;
- len = len-40;
- if (nr_match && !path_match(refname, nr_match, match))
- continue;
- ref = xmalloc(sizeof(struct ref) + len);
- ref->next = NULL;
- memcpy(ref->sha1, sha1, 20);
- memcpy(ref->name, refname, len);
- *next_ref = ref;
- next_ref = &ref->next;
- }
- return ref_list;
-}