aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-11 11:53:52 -0800
committerJunio C Hamano <gitster@pobox.com>2011-03-17 16:18:55 -0700
commite52d719266a06a8553043cb5616d9b4ce4abd27a (patch)
tree0837d066b8dc1b91d770bf9aa4961521e55c005c /builtin
parent36cfda15527d4eb50c84256307e3cb46578f975e (diff)
downloadgit-e52d719266a06a8553043cb5616d9b4ce4abd27a.tar.gz
git-e52d719266a06a8553043cb5616d9b4ce4abd27a.tar.xz
fetch-pack: objects in our alternates are available to us
Use the helper function split from the receiving end of "git push" to allow the same optimization on the receiving end of "git fetch". Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fetch-pack.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index b99941393..4c25968e1 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -9,6 +9,7 @@
#include "fetch-pack.h"
#include "remote.h"
#include "run-command.h"
+#include "transport.h"
static int transfer_unpack_limit = -1;
static int fetch_unpack_limit = -1;
@@ -217,6 +218,16 @@ static void send_request(int fd, struct strbuf *buf)
safe_write(fd, buf->buf, buf->len);
}
+static void insert_one_alternate_ref(const struct ref *ref, void *unused)
+{
+ rev_list_insert_ref(NULL, ref->old_sha1, 0, NULL);
+}
+
+static void insert_alternate_refs(void)
+{
+ foreach_alt_odb(refs_from_alternate_cb, insert_one_alternate_ref);
+}
+
static int find_common(int fd[2], unsigned char *result_sha1,
struct ref *refs)
{
@@ -235,6 +246,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
marked = 1;
for_each_ref(rev_list_insert_ref, NULL);
+ insert_alternate_refs();
fetching = 0;
for ( ; refs ; refs = refs->next) {