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 15, 2005 at 17:14 UTC
5a2e04d2031b229a242d07e11e514220e71a0d33
6 files changed
+12
-6
cache.h
+1
-1
@@ -331,7 +331,7 @@ extern int path_match(const char *path, int nr, char **match);
331
extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
332
int nr_refspec, char **refspec, int all);
333
extern int get_ack(int fd, unsigned char *result_sha1);
334
-extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match);
334
+extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, int ignore_funny);
335
336
extern struct packed_git *parse_pack_index(unsigned char *sha1);
337
extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,
clone-pack.c
+1
-1
@@ -118,7 +118,7 @@ static int clone_pack(int fd[2], int nr_match, char **match)
118
int status;
119
pid_t pid;
120
121
- get_remote_heads(fd[0], &refs, nr_match, match);
121
+ get_remote_heads(fd[0], &refs, nr_match, match, 1);
122
if (!refs) {
123
packet_flush(fd[1]);
124
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 */