aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-29 23:51:22 -0700
committerJunio C Hamano <gitster@pobox.com>2011-05-29 23:51:22 -0700
commit01f9ffbd5d3f480c9a524780d86fa0d4134841af (patch)
tree40a47451f2a72180a1497fca3ac157ff1f114226 /builtin
parenta9930e359c45302f92639e8cd0a61c9c912e0b22 (diff)
parentcff38a5e11217dc997c1ffae8d0856023e05554a (diff)
downloadgit-01f9ffbd5d3f480c9a524780d86fa0d4134841af.tar.gz
git-01f9ffbd5d3f480c9a524780d86fa0d4134841af.tar.xz
Merge branch 'jk/haves-from-alternate-odb'
* jk/haves-from-alternate-odb: receive-pack: eliminate duplicate .have refs bisect: refactor sha1_array into a generic sha1 list refactor refs_from_alternate_cb to allow passing extra data
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fetch-pack.c2
-rw-r--r--builtin/receive-pack.c16
2 files changed, 14 insertions, 4 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 56c0b4a38..436798410 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -226,7 +226,7 @@ static void insert_one_alternate_ref(const struct ref *ref, void *unused)
static void insert_alternate_refs(void)
{
- foreach_alt_odb(refs_from_alternate_cb, insert_one_alternate_ref);
+ for_each_alternate_ref(insert_one_alternate_ref, NULL);
}
#define INITIAL_FLUSH 16
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index e1ba4dc69..e1a687ad0 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -10,6 +10,7 @@
#include "remote.h"
#include "transport.h"
#include "string-list.h"
+#include "sha1-array.h"
static const char receive_pack_usage[] = "git receive-pack <git-dir>";
@@ -731,14 +732,23 @@ static int delete_only(struct command *commands)
return 1;
}
-static void add_one_alternate_ref(const struct ref *ref, void *unused)
+static void add_one_alternate_sha1(const unsigned char sha1[20], void *unused)
{
- add_extra_ref(".have", ref->old_sha1, 0);
+ add_extra_ref(".have", sha1, 0);
+}
+
+static void collect_one_alternate_ref(const struct ref *ref, void *data)
+{
+ struct sha1_array *sa = data;
+ sha1_array_append(sa, ref->old_sha1);
}
static void add_alternate_refs(void)
{
- foreach_alt_odb(refs_from_alternate_cb, add_one_alternate_ref);
+ struct sha1_array sa = SHA1_ARRAY_INIT;
+ for_each_alternate_ref(collect_one_alternate_ref, &sa);
+ sha1_array_for_each_unique(&sa, add_one_alternate_sha1, NULL);
+ sha1_array_clear(&sa);
}
int cmd_receive_pack(int argc, const char **argv, const char *prefix)