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>
This commit is contained in:
parent
d8a1deecc6
commit
1a7141ff28
2
cache.h
2
cache.h
@ -339,7 +339,7 @@ extern int path_match(const char *path, int nr, char **match);
|
|||||||
extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
|
extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
|
||||||
int nr_refspec, char **refspec, int all);
|
int nr_refspec, char **refspec, int all);
|
||||||
extern int get_ack(int fd, unsigned char *result_sha1);
|
extern int get_ack(int fd, unsigned char *result_sha1);
|
||||||
extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match);
|
extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, int ignore_funny);
|
||||||
|
|
||||||
extern struct packed_git *parse_pack_index(unsigned char *sha1);
|
extern struct packed_git *parse_pack_index(unsigned char *sha1);
|
||||||
extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,
|
extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,
|
||||||
|
@ -287,7 +287,7 @@ static int clone_pack(int fd[2], int nr_match, char **match)
|
|||||||
struct ref *refs;
|
struct ref *refs;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
get_remote_heads(fd[0], &refs, nr_match, match);
|
get_remote_heads(fd[0], &refs, nr_match, match, 1);
|
||||||
if (!refs) {
|
if (!refs) {
|
||||||
packet_flush(fd[1]);
|
packet_flush(fd[1]);
|
||||||
die("no matching remote head");
|
die("no matching remote head");
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
/*
|
/*
|
||||||
* Read all the refs from the other end
|
* 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;
|
*list = NULL;
|
||||||
for (;;) {
|
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] != ' ')
|
if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
|
||||||
die("protocol error: expected sha/ref, got '%s'", buffer);
|
die("protocol error: expected sha/ref, got '%s'", buffer);
|
||||||
name = buffer + 41;
|
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))
|
if (nr_match && !path_match(name, nr_match, match))
|
||||||
continue;
|
continue;
|
||||||
ref = xcalloc(1, sizeof(*ref) + len - 40);
|
ref = xcalloc(1, sizeof(*ref) + len - 40);
|
||||||
|
@ -81,7 +81,7 @@ static int fetch_pack(int fd[2], int nr_match, char **match)
|
|||||||
int status;
|
int status;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
get_remote_heads(fd[0], &ref, nr_match, match);
|
get_remote_heads(fd[0], &ref, nr_match, match, 1);
|
||||||
if (!ref) {
|
if (!ref) {
|
||||||
packet_flush(fd[1]);
|
packet_flush(fd[1]);
|
||||||
die("no matching remote head");
|
die("no matching remote head");
|
||||||
|
@ -11,7 +11,7 @@ static int peek_remote(int fd[2])
|
|||||||
{
|
{
|
||||||
struct ref *ref;
|
struct ref *ref;
|
||||||
|
|
||||||
get_remote_heads(fd[0], &ref, 0, NULL);
|
get_remote_heads(fd[0], &ref, 0, NULL, 0);
|
||||||
packet_flush(fd[1]);
|
packet_flush(fd[1]);
|
||||||
|
|
||||||
while (ref) {
|
while (ref) {
|
||||||
|
@ -181,7 +181,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
|
|||||||
int new_refs;
|
int new_refs;
|
||||||
|
|
||||||
/* No funny business with the matcher */
|
/* No funny business with the matcher */
|
||||||
remote_tail = get_remote_heads(in, &remote_refs, 0, NULL);
|
remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, 1);
|
||||||
get_local_heads();
|
get_local_heads();
|
||||||
|
|
||||||
/* match them up */
|
/* match them up */
|
||||||
|
Loading…
Reference in New Issue
Block a user