@matheusbsbs / matheus-bagliano / commits / 1a7141ff28
Fork 0

Ignore funny refname sent from remote

This allows the remote side (most notably, upload-pack) to show additional information without affecting the downloader. Peek-remote does not ignore them -- this is to make it useful for Pasky's automatic tag following. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Oct 13, 2005 at 18:57 UTC 1a7141ff28e217312da4b289127875905c6ec479
6 files changed +12 -6
cache.h
+1 -1
@@ -339,7 +339,7 @@ extern int path_match(const char *path, int nr, char **match);
339 extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
340 int nr_refspec, char **refspec, int all);
341 extern int get_ack(int fd, unsigned char *result_sha1);
342 -extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match);
342 +extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, int ignore_funny);
343
344 extern struct packed_git *parse_pack_index(unsigned char *sha1);
345 extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,
clone-pack.c
+1 -1
@@ -287,7 +287,7 @@ static int clone_pack(int fd[2], int nr_match, char **match)
287 struct ref *refs;
288 int status;
289
290 - get_remote_heads(fd[0], &refs, nr_match, match);
290 + get_remote_heads(fd[0], &refs, nr_match, match, 1);
291 if (!refs) {
292 packet_flush(fd[1]);
293 die("no matching remote head");
connect.c
+7 -1
@@ -10,7 +10,8 @@
10 /*
11 * Read all the refs from the other end
12 */
13 -struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match)
13 +struct ref **get_remote_heads(int in, struct ref **list,
14 + int nr_match, char **match, int ignore_funny)
15 {
16 *list = NULL;
17 for (;;) {
@@ -29,6 +30,11 @@ struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **ma
30 if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
31 die("protocol error: expected sha/ref, got '%s'", buffer);
32 name = buffer + 41;
33 +
34 + if (ignore_funny && 45 < len && !memcmp(name, "refs/", 5) &&
35 + check_ref_format(name + 5))
36 + continue;
37 +
38 if (nr_match && !path_match(name, nr_match, match))
39 continue;
40 ref = xcalloc(1, sizeof(*ref) + len - 40);
fetch-pack.c
+1 -1
@@ -81,7 +81,7 @@ static int fetch_pack(int fd[2], int nr_match, char **match)
81 int status;
82 pid_t pid;
83
84 - get_remote_heads(fd[0], &ref, nr_match, match);
84 + get_remote_heads(fd[0], &ref, nr_match, match, 1);
85 if (!ref) {
86 packet_flush(fd[1]);
87 die("no matching remote head");
peek-remote.c
+1 -1
@@ -11,7 +11,7 @@ static int peek_remote(int fd[2])
11 {
12 struct ref *ref;
13
14 - get_remote_heads(fd[0], &ref, 0, NULL);
14 + get_remote_heads(fd[0], &ref, 0, NULL, 0);
15 packet_flush(fd[1]);
16
17 while (ref) {
send-pack.c
+1 -1
@@ -181,7 +181,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
181 int new_refs;
182
183 /* No funny business with the matcher */
184 - remote_tail = get_remote_heads(in, &remote_refs, 0, NULL);
184 + remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, 1);
185 get_local_heads();
186
187 /* match them up */