aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-22 21:37:53 -0700
committerJunio C Hamano <gitster@pobox.com>2011-03-22 21:37:53 -0700
commit91b3c7ce8e189b90d3203265c9625806a15045e1 (patch)
tree2287f84dbd07706e74db16896e8e7f3a7d6dd7ed /builtin
parent1c92e394468c927f129c8f2a138b760f884e3bed (diff)
parente52d719266a06a8553043cb5616d9b4ce4abd27a (diff)
downloadgit-91b3c7ce8e189b90d3203265c9625806a15045e1.tar.gz
git-91b3c7ce8e189b90d3203265c9625806a15045e1.tar.xz
Merge branch 'jc/maint-fetch-alt'
* jc/maint-fetch-alt: fetch-pack: objects in our alternates are available to us refs_from_alternate: helper to use refs from alternates Conflicts: builtin/receive-pack.c
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fetch-pack.c12
-rw-r--r--builtin/receive-pack.c35
2 files changed, 15 insertions, 32 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index ef398620a..28d6900bb 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/builtin/receive-pack.c b/builtin/receive-pack.c
index d8e2c5fca..27050e7c1 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -731,43 +731,14 @@ static int delete_only(struct command *commands)
return 1;
}
-static int add_refs_from_alternate(struct alternate_object_database *e, void *unused)
+static void add_one_alternate_ref(const struct ref *ref, void *unused)
{
- char *other;
- size_t len;
- struct remote *remote;
- struct transport *transport;
- const struct ref *extra;
-
- e->name[-1] = '\0';
- other = xstrdup(real_path(e->base));
- e->name[-1] = '/';
- len = strlen(other);
-
- while (other[len-1] == '/')
- other[--len] = '\0';
- if (len < 8 || memcmp(other + len - 8, "/objects", 8))
- return 0;
- /* Is this a git repository with refs? */
- memcpy(other + len - 8, "/refs", 6);
- if (!is_directory(other))
- return 0;
- other[len - 8] = '\0';
- remote = remote_get(other);
- transport = transport_get(remote, other);
- for (extra = transport_get_remote_refs(transport);
- extra;
- extra = extra->next) {
- add_extra_ref(".have", extra->old_sha1, 0);
- }
- transport_disconnect(transport);
- free(other);
- return 0;
+ add_extra_ref(".have", ref->old_sha1, 0);
}
static void add_alternate_refs(void)
{
- foreach_alt_odb(add_refs_from_alternate, NULL);
+ foreach_alt_odb(refs_from_alternate_cb, add_one_alternate_ref);
}
int cmd_receive_pack(int argc, const char **argv, const char *prefix)