Re: [WIP 06/15] transport: use get_refs_via_connect to get refs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 6, 2017, 22:10 UTC
- Message-ID
- <xmqqmv2vfqxh.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20171204235823.63299-7-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
Show 25 quoted lines
> Remove code duplication and use the existing 'get_refs_via_connect()'
> function to retrieve a remote's heads in 'fetch_refs_via_pack()' and
> 'git_transport_push()'.
>
> Signed-off-by: Brandon Williams <bmwill@google.com>
> ---
> transport.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/transport.c b/transport.c
> index d75ff0514..7c969f285 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -230,12 +230,8 @@ static int fetch_refs_via_pack(struct transport *transport,
> args.cloning = transport->cloning;
> args.update_shallow = data->options.update_shallow;
>
> - if (!data->got_remote_heads) {
> - connect_setup(transport, 0);
> - get_remote_heads(data->fd[0], NULL, 0, &refs_tmp, 0,
> - NULL, &data->shallow);
> - data->got_remote_heads = 1;
> - }
> + if (!data->got_remote_heads)
> + refs_tmp = get_refs_via_connect(transport, 0);The updated version is equivalent to the original as long as transport->data->extra_have is empty at this point. Were we deliberately sending NULL, instead of &data->extra_have, in the original, or is it a mere oversight?
The same comment applies to the other hunk of this patch.