summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e923eae)
raw | patch | inline | side by side (parent: e923eae)
author | Tay Ray Chuan <rctay89@gmail.com> | |
Tue, 16 Feb 2010 07:18:21 +0000 (15:18 +0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 16 Feb 2010 17:11:22 +0000 (09:11 -0800) |
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>
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>
transport.c | patch | blob | history | |
transport.h | patch | blob | history |
diff --git a/transport.c b/transport.c
index 3846aacb476b552cefddd8774b9a055e353b6ebc..08e4fa0354d64e2b931be68ed8da111b97273523 100644 (file)
--- a/transport.c
+++ b/transport.c
if (!remote)
die("No remote provided to transport_get()");
+ ret->got_remote_refs = 0;
ret->remote = remote;
helper = remote->foreign_vcs;
const struct ref *transport_get_remote_refs(struct transport *transport)
{
- if (!transport->remote_refs)
+ if (!transport->got_remote_refs) {
transport->remote_refs = transport->get_refs_list(transport, 0);
+ transport->got_remote_refs = 1;
+ }
return transport->remote_refs;
}
diff --git a/transport.h b/transport.h
index 7cea5cc7234185b1c37ada818dfa1a9114621ad2..6dd9ae182fe12c53860a6af02461ff819d59fd6e 100644 (file)
--- a/transport.h
+++ b/transport.h
void *data;
const struct ref *remote_refs;
+ /**
+ * Indicates whether we already called get_refs_list(); set by
+ * transport.c::transport_get_remote_refs().
+ */
+ unsigned got_remote_refs : 1;
+
/**
* Returns 0 if successful, positive if the option is not
* recognized or is inapplicable, and negative if the option