]> git.ipfire.org Git - thirdparty/git.git/commit - transport-helper.c
transport-helper: skip ls-refs if unnecessary
authorJonathan Tan <jonathantanmy@google.com>
Wed, 21 Aug 2019 22:20:09 +0000 (15:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2019 21:20:35 +0000 (14:20 -0700)
commitac3fda82bfe1c9e99c5838d052c678c78139ee34
treed25670cb823e968103065070b0e6c6c207d99c42
parent745f6812895b31c02b29bdfe4ae8e5498f776c26
transport-helper: skip ls-refs if unnecessary

Commit e70a3030e7 ("fetch: do not list refs if fetching only hashes",
2018-10-07) and its ancestors taught Git, as an optimization, to skip
the ls-refs step when it is not necessary during a protocol v2 fetch
(for example, when lazy fetching a missing object in a partial clone, or
when running "git fetch --no-tags <remote> <SHA-1>"). But that was only
done for natively supported protocols; in particular, HTTP was not
supported.

Teach Git to skip ls-refs when using remote helpers that support connect
or stateless-connect. To do this, fetch() is made an acceptable entry
point. Because fetch() can now be the first function in the vtable
called, "get_helper(transport);" has to be added to the beginning of
that function to set the transport up (if not yet set up) before
process_connect() is invoked.

When fetch() is called, the transport could be taken over (this happens
if "connect" or "stateless-connect" is successfully run without any
"fallback" response), or not. If the transport is taken over, execution
continues like execution for natively supported protocols
(fetch_refs_via_pack() is executed, which will fetch refs using ls-refs
if needed). If not, the remote helper interface will invoke
get_refs_list() if it hasn't been invoked yet, preserving existing
behavior.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5702-protocol-v2.sh
transport-helper.c