transport: use get_refs_via_connect to get refs

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed Mar 14, 2018 at 11:31 UTC 635365eb2f67bc17482c5dbe076f20832cf92ae2
1 file changed +4 -14
transport.c
+4 -14
@@ -230,12 +230,8 @@ static int fetch_refs_via_pack(struct transport *transport,
230 args.cloning = transport->cloning;
231 args.update_shallow = data->options.update_shallow;
232
233 - if (!data->got_remote_heads) {
234 - connect_setup(transport, 0);
235 - get_remote_heads(data->fd[0], NULL, 0, &refs_tmp, 0,
236 - NULL, &data->shallow);
237 - data->got_remote_heads = 1;
238 - }
233 + if (!data->got_remote_heads)
234 + refs_tmp = get_refs_via_connect(transport, 0);
235
236 refs = fetch_pack(&args, data->fd, data->conn,
237 refs_tmp ? refs_tmp : transport->remote_refs,
@@ -541,14 +537,8 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
537 struct send_pack_args args;
538 int ret;
539
544 - if (!data->got_remote_heads) {
545 - struct ref *tmp_refs;
546 - connect_setup(transport, 1);
547 -
548 - get_remote_heads(data->fd[0], NULL, 0, &tmp_refs, REF_NORMAL,
549 - NULL, &data->shallow);
550 - data->got_remote_heads = 1;
551 - }
540 + if (!data->got_remote_heads)
541 + get_refs_via_connect(transport, 1);
542
543 memset(&args, 0, sizeof(args));
544 args.send_mirror = !!(flags & TRANSPORT_PUSH_MIRROR);