@matheusbsbs / matheus-bagliano / commits / b0d66e156c
Fork 0

transport: add got_remote_refs flag

transport_get_remote_refs() in tranport.c checks transport->remote_refs to determine whether transport->get_refs_list() should be invoked. The logic is "if it is NULL, we haven't run ls-remote to find out yet". However, transport->remote_refs could still be NULL while cloning from an empty repository. This causes get_refs_list() to be run unnecessarily. Introduce a flag, transport->got_remote_refs, to more explicitly record if we have run transport->get_refs_list() already. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tay Ray Chuan committed Feb 16, 2010 at 15:18 UTC b0d66e156c5b312d468344569202d8ca4094f67f
2 files changed +10 -1
transport.c
+4 -1
@@ -918,6 +918,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
918 if (!remote)
919 die("No remote provided to transport_get()");
920
921 + ret->got_remote_refs = 0;
922 ret->remote = remote;
923 helper = remote->foreign_vcs;
924
@@ -1079,8 +1080,10 @@ int transport_push(struct transport *transport,
1080
1081 const struct ref *transport_get_remote_refs(struct transport *transport)
1082 {
1082 - if (!transport->remote_refs)
1083 + if (!transport->got_remote_refs) {
1084 transport->remote_refs = transport->get_refs_list(transport, 0);
1085 + transport->got_remote_refs = 1;
1086 + }
1087
1088 return transport->remote_refs;
1089 }
transport.h
+6
@@ -19,6 +19,12 @@ struct transport {
19 void *data;
20 const struct ref *remote_refs;
21
22 + /**
23 + * Indicates whether we already called get_refs_list(); set by
24 + * transport.c::transport_get_remote_refs().
25 + */
26 + unsigned got_remote_refs : 1;
27 +
28 /**
29 * Returns 0 if successful, positive if the option is not
30 * recognized or is inapplicable, and negative if the option