aboutsummaryrefslogtreecommitdiffstats
path: root/bundle.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-04-23 13:58:50 -0700
committerJunio C Hamano <gitster@pobox.com>2025-04-23 13:58:50 -0700
commitbb74c0abbc31da35be52999569ea481ebd149d1d (patch)
treee10db152ee6486a1b9af0f7990a140730ebe0ce2 /bundle.c
parentMerge branch 'pb/perf-test-fixes' (diff)
parentbundle: fix non-linear performance scaling with refs (diff)
downloadgit-bb74c0abbc31da35be52999569ea481ebd149d1d.tar.gz
git-bb74c0abbc31da35be52999569ea481ebd149d1d.zip
Merge branch 'kn/bundle-dedup-optim'
Optimize the code to dedup references recorded in a bundle file. * kn/bundle-dedup-optim: bundle: fix non-linear performance scaling with refs t6020: test for duplicate refnames in bundle creation
Diffstat (limited to 'bundle.c')
-rw-r--r--bundle.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/bundle.c b/bundle.c
index d7ad690843..0614426e20 100644
--- a/bundle.c
+++ b/bundle.c
@@ -384,6 +384,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
{
int i;
int ref_count = 0;
+ struct strset objects = STRSET_INIT;
for (i = 0; i < revs->pending.nr; i++) {
struct object_array_entry *e = revs->pending.objects + i;
@@ -401,6 +402,9 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
flag = 0;
display_ref = (flag & REF_ISSYMREF) ? e->name : ref;
+ if (strset_contains(&objects, display_ref))
+ goto skip_write_ref;
+
if (e->item->type == OBJ_TAG &&
!is_tag_in_date_range(e->item, revs)) {
e->item->flags |= UNINTERESTING;
@@ -423,6 +427,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
}
ref_count++;
+ strset_add(&objects, display_ref);
write_or_die(bundle_fd, oid_to_hex(&e->item->oid), the_hash_algo->hexsz);
write_or_die(bundle_fd, " ", 1);
write_or_die(bundle_fd, display_ref, strlen(display_ref));
@@ -431,6 +436,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
free(ref);
}
+ strset_clear(&objects);
+
/* end header */
write_or_die(bundle_fd, "\n", 1);
return ref_count;
@@ -566,7 +573,6 @@ int create_bundle(struct repository *r, const char *path,
*/
revs.blob_objects = revs.tree_objects = 0;
traverse_commit_list(&revs, write_bundle_prerequisites, NULL, &bpi);
- object_array_remove_duplicates(&revs_copy.pending);
/* write bundle refs */
ref_count = write_bundle_refs(bundle_fd, &revs_copy);