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
@ -14,6 +14,7 @@
|
||||
#include "sha1-array.h"
|
||||
#include "gpg-interface.h"
|
||||
#include "gettext.h"
|
||||
#include "protocol.h"
|
||||
|
||||
static const char * const send_pack_usage[] = {
|
||||
N_("git send-pack [--all | --mirror] [--dry-run] [--force] "
|
||||
@ -154,6 +155,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
|
||||
int progress = -1;
|
||||
int from_stdin = 0;
|
||||
struct push_cas_option cas = {0};
|
||||
struct packet_reader reader;
|
||||
|
||||
struct option options[] = {
|
||||
OPT__VERBOSITY(&verbose),
|
||||
@ -256,8 +258,19 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
|
||||
args.verbose ? CONNECT_VERBOSE : 0);
|
||||
}
|
||||
|
||||
get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL,
|
||||
&extra_have, &shallow);
|
||||
packet_reader_init(&reader, fd[0], NULL, 0,
|
||||
PACKET_READ_CHOMP_NEWLINE |
|
||||
PACKET_READ_GENTLE_ON_EOF);
|
||||
|
||||
switch (discover_version(&reader)) {
|
||||
case protocol_v1:
|
||||
case protocol_v0:
|
||||
get_remote_heads(&reader, &remote_refs, REF_NORMAL,
|
||||
&extra_have, &shallow);
|
||||
break;
|
||||
case protocol_unknown_version:
|
||||
BUG("unknown protocol version");
|
||||
}
|
||||
|
||||
transport_verify_remote_names(nr_refspecs, refspecs);
|
||||
|
||||
|
Reference in New Issue
Block a user