зеркало из https://github.com/microsoft/git.git
transport: allow skipping of ref listing
The get_refs_via_connect() function both performs the handshake (including determining the protocol version) and obtaining the list of remote refs. However, the fetch protocol v2 supports fetching objects without the listing of refs, so make it possible for the user to skip the listing by creating a new handshake() function. This will be used in a subsequent commit. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
f84b9b09d4
Коммит
99bcb883cb
29
transport.c
29
transport.c
|
@ -252,8 +252,18 @@ static int connect_setup(struct transport *transport, int for_push)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct ref *get_refs_via_connect(struct transport *transport, int for_push,
|
||||
const struct argv_array *ref_prefixes)
|
||||
/*
|
||||
* Obtains the protocol version from the transport and writes it to
|
||||
* transport->data->version, first connecting if not already connected.
|
||||
*
|
||||
* If the protocol version is one that allows skipping the listing of remote
|
||||
* refs, and must_list_refs is 0, the listing of remote refs is skipped and
|
||||
* this function returns NULL. Otherwise, this function returns the list of
|
||||
* remote refs.
|
||||
*/
|
||||
static struct ref *handshake(struct transport *transport, int for_push,
|
||||
const struct argv_array *ref_prefixes,
|
||||
int must_list_refs)
|
||||
{
|
||||
struct git_transport_data *data = transport->data;
|
||||
struct ref *refs = NULL;
|
||||
|
@ -268,8 +278,10 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
|
|||
data->version = discover_version(&reader);
|
||||
switch (data->version) {
|
||||
case protocol_v2:
|
||||
get_remote_refs(data->fd[1], &reader, &refs, for_push,
|
||||
ref_prefixes, transport->server_options);
|
||||
if (must_list_refs)
|
||||
get_remote_refs(data->fd[1], &reader, &refs, for_push,
|
||||
ref_prefixes,
|
||||
transport->server_options);
|
||||
break;
|
||||
case protocol_v1:
|
||||
case protocol_v0:
|
||||
|
@ -283,9 +295,18 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
|
|||
}
|
||||
data->got_remote_heads = 1;
|
||||
|
||||
if (reader.line_peeked)
|
||||
BUG("buffer must be empty at the end of handshake()");
|
||||
|
||||
return refs;
|
||||
}
|
||||
|
||||
static struct ref *get_refs_via_connect(struct transport *transport, int for_push,
|
||||
const struct argv_array *ref_prefixes)
|
||||
{
|
||||
return handshake(transport, for_push, ref_prefixes, 1);
|
||||
}
|
||||
|
||||
static int fetch_refs_via_pack(struct transport *transport,
|
||||
int nr_heads, struct ref **to_fetch)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче