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

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>

Junio C Hamano committed Mar 11, 2011 at 11:53 UTC e52d719266a06a8553043cb5616d9b4ce4abd27a
2 files changed +13 -1
builtin/fetch-pack.c
+12
@@ -9,6 +9,7 @@
9 #include "fetch-pack.h"
10 #include "remote.h"
11 #include "run-command.h"
12 +#include "transport.h"
13
14 static int transfer_unpack_limit = -1;
15 static int fetch_unpack_limit = -1;
@@ -217,6 +218,16 @@ static void send_request(int fd, struct strbuf *buf)
218 safe_write(fd, buf->buf, buf->len);
219 }
220
221 +static void insert_one_alternate_ref(const struct ref *ref, void *unused)
222 +{
223 + rev_list_insert_ref(NULL, ref->old_sha1, 0, NULL);
224 +}
225 +
226 +static void insert_alternate_refs(void)
227 +{
228 + foreach_alt_odb(refs_from_alternate_cb, insert_one_alternate_ref);
229 +}
230 +
231 static int find_common(int fd[2], unsigned char *result_sha1,
232 struct ref *refs)
233 {
@@ -235,6 +246,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
246 marked = 1;
247
248 for_each_ref(rev_list_insert_ref, NULL);
249 + insert_alternate_refs();
250
251 fetching = 0;
252 for ( ; refs ; refs = refs->next) {
t/t5501-fetch-push-alternates.sh
+1 -1
@@ -54,7 +54,7 @@ test_expect_success 'pushing into a repository with the same alternate' '
54 test_cmp one.count receiver.count
55 '
56
57 -test_expect_failure 'fetching from a repository with the same alternate' '
57 +test_expect_success 'fetching from a repository with the same alternate' '
58 (
59 cd fetcher &&
60 git fetch ../one master:refs/heads/it &&