Skip to content

Commit 1a7141f

Browse files
author
Junio C Hamano
committed
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 <[email protected]>
1 parent d8a1dee commit 1a7141f

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ extern int path_match(const char *path, int nr, char **match);
339339
extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
340340
int nr_refspec, char **refspec, int all);
341341
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);
343343

344344
extern struct packed_git *parse_pack_index(unsigned char *sha1);
345345
extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,

clone-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static int clone_pack(int fd[2], int nr_match, char **match)
287287
struct ref *refs;
288288
int status;
289289

290-
get_remote_heads(fd[0], &refs, nr_match, match);
290+
get_remote_heads(fd[0], &refs, nr_match, match, 1);
291291
if (!refs) {
292292
packet_flush(fd[1]);
293293
die("no matching remote head");

connect.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
/*
1111
* Read all the refs from the other end
1212
*/
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)
1415
{
1516
*list = NULL;
1617
for (;;) {
@@ -29,6 +30,11 @@ struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **ma
2930
if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
3031
die("protocol error: expected sha/ref, got '%s'", buffer);
3132
name = buffer + 41;
33+
34+
if (ignore_funny && 45 < len && !memcmp(name, "refs/", 5) &&
35+
check_ref_format(name + 5))
36+
continue;
37+
3238
if (nr_match && !path_match(name, nr_match, match))
3339
continue;
3440
ref = xcalloc(1, sizeof(*ref) + len - 40);

fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int fetch_pack(int fd[2], int nr_match, char **match)
8181
int status;
8282
pid_t pid;
8383

84-
get_remote_heads(fd[0], &ref, nr_match, match);
84+
get_remote_heads(fd[0], &ref, nr_match, match, 1);
8585
if (!ref) {
8686
packet_flush(fd[1]);
8787
die("no matching remote head");

peek-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static int peek_remote(int fd[2])
1111
{
1212
struct ref *ref;
1313

14-
get_remote_heads(fd[0], &ref, 0, NULL);
14+
get_remote_heads(fd[0], &ref, 0, NULL, 0);
1515
packet_flush(fd[1]);
1616

1717
while (ref) {

send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
181181
int new_refs;
182182

183183
/* 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);
185185
get_local_heads();
186186

187187
/* match them up */

0 commit comments

Comments
 (0)