Skip to content

Commit

Permalink
connect: pass full packet reader when parsing v2 refs
Browse files Browse the repository at this point in the history
When we're parsing refs, we need to know not only what the line we're
parsing is, but also the hash algorithm we should use to parse it, which
is stored in the reader object.  Pass the packet reader object through
to the protocol v2 ref parsing function.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
bk2204 authored and gitster committed May 27, 2020
1 parent 7f46e7e commit 67e9a70
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions connect.c
Expand Up @@ -374,14 +374,15 @@ struct ref **get_remote_heads(struct packet_reader *reader,
}

/* Returns 1 when a valid ref has been added to `list`, 0 otherwise */
static int process_ref_v2(const char *line, struct ref ***list)
static int process_ref_v2(struct packet_reader *reader, struct ref ***list)
{
int ret = 1;
int i = 0;
struct object_id old_oid;
struct ref *ref;
struct string_list line_sections = STRING_LIST_INIT_DUP;
const char *end;
const char *line = reader->line;

/*
* Ref lines have a number of fields which are space deliminated. The
Expand Down Expand Up @@ -469,7 +470,7 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,

/* Process response from server */
while (packet_reader_read(reader) == PACKET_READ_NORMAL) {
if (!process_ref_v2(reader->line, &list))
if (!process_ref_v2(reader, &list))
die(_("invalid ls-refs response: %s"), reader->line);
}

Expand Down

0 comments on commit 67e9a70

Please sign in to comment.