aboutsummaryrefslogtreecommitdiff
path: root/builtin-fetch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-11-20 23:44:35 -0800
committerJunio C Hamano <gitster@pobox.com>2009-11-20 23:44:35 -0800
commit1b8dbdb41e503f6829be4e1d8ada4c8eabbc49bd (patch)
tree1281bbf5a21e3381efde6ca8866c0cd17aecea25 /builtin-fetch.c
parent7a0d61bb45055cacf85111e7c48dfb9054b0abb0 (diff)
parent95c96d48e65a597cfd2bf7228ddc8c7ca30b55b7 (diff)
downloadgit-1b8dbdb41e503f6829be4e1d8ada4c8eabbc49bd.tar.gz
git-1b8dbdb41e503f6829be4e1d8ada4c8eabbc49bd.tar.xz
Merge branch 'jp/fetch-cull-many-refs'
* jp/fetch-cull-many-refs: remote: fix use-after-free error detected by glibc in ref_remove_duplicates fetch: Speed up fetch of large numbers of refs remote: Make ref_remove_duplicates faster for large numbers of refs
Diffstat (limited to 'builtin-fetch.c')
-rw-r--r--builtin-fetch.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c
index f871f2bfe..272886039 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -489,7 +489,8 @@ static int add_existing(const char *refname, const unsigned char *sha1,
int flag, void *cbdata)
{
struct string_list *list = (struct string_list *)cbdata;
- string_list_insert(refname, list);
+ struct string_list_item *item = string_list_insert(refname, list);
+ item->util = (void *)sha1;
return 0;
}
@@ -615,9 +616,14 @@ static void check_not_current_branch(struct ref *ref_map)
static int do_fetch(struct transport *transport,
struct refspec *refs, int ref_count)
{
+ struct string_list existing_refs = { NULL, 0, 0, 0 };
+ struct string_list_item *peer_item = NULL;
struct ref *ref_map;
struct ref *rm;
int autotags = (transport->remote->fetch_tags == 1);
+
+ for_each_ref(add_existing, &existing_refs);
+
if (transport->remote->fetch_tags == 2 && tags != TAGS_UNSET)
tags = TAGS_SET;
if (transport->remote->fetch_tags == -1)
@@ -640,8 +646,13 @@ static int do_fetch(struct transport *transport,
check_not_current_branch(ref_map);
for (rm = ref_map; rm; rm = rm->next) {
- if (rm->peer_ref)
- read_ref(rm->peer_ref->name, rm->peer_ref->old_sha1);
+ if (rm->peer_ref) {
+ peer_item = string_list_lookup(rm->peer_ref->name,
+ &existing_refs);
+ if (peer_item)
+ hashcpy(rm->peer_ref->old_sha1,
+ peer_item->util);
+ }
}
if (tags == TAGS_DEFAULT && autotags)