From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>
Subject: [PATCH 2/2] fetch-pack: objects in our alternates are available to us
Date: Fri, 11 Mar 2011 12:51:11 -0800 [thread overview]
Message-ID: <1299876671-12838-2-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1299876671-12838-1-git-send-email-gitster@pobox.com>
Use the helper function split from 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>
---
builtin/fetch-pack.c | 12 ++++++++++++
t/t5501-fetch-push-alternates.sh | 2 +-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index b999413..4c25968 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) {
diff --git a/t/t5501-fetch-push-alternates.sh b/t/t5501-fetch-push-alternates.sh
index 564ef7c..a0f3644 100755
--- a/t/t5501-fetch-push-alternates.sh
+++ b/t/t5501-fetch-push-alternates.sh
@@ -54,7 +54,7 @@ test_expect_success 'pushing into a repository with the same alternate' '
test_cmp one.count receiver.count
'
-test_expect_failure 'fetching from a repository with the same alternate' '
+test_expect_success 'fetching from a repository with the same alternate' '
(
cd fetcher &&
git fetch ../one master:refs/heads/it &&
--
1.7.4.1.404.g62d316
next prev parent reply other threads:[~2011-03-11 20:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-11 20:51 [PATCH 1/2] refs_from_alternate: helper to use refs from alternates Junio C Hamano
2011-03-11 20:51 ` Junio C Hamano [this message]
2011-03-15 1:57 ` [PATCH 2/2] fetch-pack: objects in our alternates are available to us Shawn Pearce
2011-03-11 23:08 ` [PATCH 1/2] refs_from_alternate: helper to use refs from alternates Johannes Sixt
2011-03-11 23:15 ` Junio C Hamano
2011-03-11 23:32 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1299876671-12838-2-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).