summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8051a03)
raw | patch | inline | side by side (parent: 8051a03)
author | Nicolas Pitre <nico@fluxnic.net> | |
Mon, 8 Feb 2010 15:39:01 +0000 (10:39 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 8 Feb 2010 18:56:21 +0000 (10:56 -0800) |
This reverts most of commit a2430dde8ceaaaabf05937438249397b883ca77a.
That commit made the situation better for repositories with relatively
small number of objects. However with many objects and a small pack size
limit, the time required to complete the repack tends towards O(n^2),
or even much worse with long delta chains.
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
That commit made the situation better for repositories with relatively
small number of objects. However with many objects and a small pack size
limit, the time required to complete the repack tends towards O(n^2),
or even much worse with long delta chains.
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-pack-objects.c | patch | blob | history | |
t/t5300-pack-object.sh | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index dcfe62aa02ca69cad39b4dd681a60f052b20aba5..e1d3adf405bb6ac842a3415e0461b4772396060d 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
if (e->idx.offset || e->preferred_base)
return -1;
- /*
- * If we are deltified, attempt to write out base object first.
- * If that fails due to the pack size limit then the current
- * object might still possibly fit undeltified within that limit.
- */
- if (e->delta)
- write_one(f, e->delta, offset);
+ /* if we are deltified, write out base object first. */
+ if (e->delta && !write_one(f, e->delta, offset))
+ return 0;
e->idx.offset = *offset;
size = write_object(f, e, *offset);
sha1write(f, &hdr, sizeof(hdr));
offset = sizeof(hdr);
nr_written = 0;
- for (i = 0; i < nr_objects; i++)
- if (write_one(f, objects + i, &offset) == 1)
- display_progress(progress_state, written);
+ for (; i < nr_objects; i++) {
+ if (!write_one(f, objects + i, &offset))
+ break;
+ display_progress(progress_state, written);
+ }
/*
* Did we write the wrong # entries in the header?
written_list[j]->offset = (off_t)-1;
}
nr_remaining -= nr_written;
- } while (nr_remaining);
+ } while (nr_remaining && i < nr_objects);
free(written_list);
stop_progress(&progress_state);
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 1058d981dc85b2a7b63aca6e9cbb48f07e0a09a3..7649b810b1469724ff738fb0bf8b23ea61b37bda 100755 (executable)
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
test_expect_success 'tolerate packsizelimit smaller than biggest object' '
git config pack.packSizeLimit 1 &&
packname_11=$(git pack-objects test-11 <obj-list) &&
- test 3 = $(ls test-11-*.pack | wc -l)
+ test 5 = $(ls test-11-*.pack | wc -l)
'
test_expect_success 'verify resulting packs' '