Skip to content

Commit 635365e

Browse files
bmwillgitster
authored andcommitted
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>
1 parent ae2948f commit 635365e

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

transport.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,8 @@ static int fetch_refs_via_pack(struct transport *transport,
230230
args.cloning = transport->cloning;
231231
args.update_shallow = data->options.update_shallow;
232232

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);
239235

240236
refs = fetch_pack(&args, data->fd, data->conn,
241237
refs_tmp ? refs_tmp : transport->remote_refs,
@@ -541,14 +537,8 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
541537
struct send_pack_args args;
542538
int ret;
543539

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);
552542

553543
memset(&args, 0, sizeof(args));
554544
args.send_mirror = !!(flags & TRANSPORT_PUSH_MIRROR);

0 commit comments

Comments
 (0)