diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2018-09-27 12:24:05 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-10-07 09:53:15 +0900 |
commit | 01775651481ecd9c7288a85cfb7999f7f38ab37c (patch) | |
tree | 3e2dfaec7103a81426e4d8dd3a7e16ddd6fa0587 /transport.c | |
parent | 99bcb883cb2bd2d27939a831a66d794770427e98 (diff) | |
download | git-01775651481ecd9c7288a85cfb7999f7f38ab37c.tar.gz |
transport: do not list refs if possible
When all refs to be fetched are exact OIDs, it is possible to perform a
fetch without requiring the remote to list refs if protocol v2 is used.
Teach Git to do this.
This currently has an effect only for lazy fetches done from partial
clones. The change necessary to likewise optimize "git fetch <remote>
<sha-1>" will be done in a subsequent patch.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r-- | transport.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/transport.c b/transport.c index 5fb9ff6b56..4329cca8e5 100644 --- a/transport.c +++ b/transport.c @@ -341,8 +341,17 @@ static int fetch_refs_via_pack(struct transport *transport, args.server_options = transport->server_options; args.negotiation_tips = data->options.negotiation_tips; - if (!data->got_remote_heads) - refs_tmp = get_refs_via_connect(transport, 0, NULL); + if (!data->got_remote_heads) { + int i; + int must_list_refs = 0; + for (i = 0; i < nr_heads; i++) { + if (!to_fetch[i]->exact_oid) { + must_list_refs = 1; + break; + } + } + refs_tmp = handshake(transport, 0, NULL, must_list_refs); + } switch (data->version) { case protocol_v2: |