connect: discover protocol version outside of get_remote_heads
In order to prepare for the addition of protocol_v2 push the protocol version discovery outside of 'get_remote_heads()'. This will allow for keeping the logic for processing the reference advertisement for protocol_v1 and protocol_v0 separate from the logic for protocol_v2. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7e3e479b90
commit
ad6ac1244f
@ -1,6 +1,7 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "remote.h"
|
||||
#include "connect.h"
|
||||
#include "strbuf.h"
|
||||
#include "walker.h"
|
||||
#include "http.h"
|
||||
@ -13,6 +14,7 @@
|
||||
#include "credential.h"
|
||||
#include "sha1-array.h"
|
||||
#include "send-pack.h"
|
||||
#include "protocol.h"
|
||||
|
||||
static struct remote *remote;
|
||||
/* always ends with a trailing slash */
|
||||
@ -176,8 +178,22 @@ static struct discovery *last_discovery;
|
||||
static struct ref *parse_git_refs(struct discovery *heads, int for_push)
|
||||
{
|
||||
struct ref *list = NULL;
|
||||
get_remote_heads(-1, heads->buf, heads->len, &list,
|
||||
for_push ? REF_NORMAL : 0, NULL, &heads->shallow);
|
||||
struct packet_reader reader;
|
||||
|
||||
packet_reader_init(&reader, -1, heads->buf, heads->len,
|
||||
PACKET_READ_CHOMP_NEWLINE |
|
||||
PACKET_READ_GENTLE_ON_EOF);
|
||||
|
||||
switch (discover_version(&reader)) {
|
||||
case protocol_v1:
|
||||
case protocol_v0:
|
||||
get_remote_heads(&reader, &list, for_push ? REF_NORMAL : 0,
|
||||
NULL, &heads->shallow);
|
||||
break;
|
||||
case protocol_unknown_version:
|
||||
BUG("unknown protocol version");
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user