Revert "pack-objects: fix pack generation when using pack_size_limit"
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>
Nicolas Pitre committed
Feb 8, 2010 at 10:39 UTC
720c9f7bda20d8f307745772374647c1a2076b3d
2 files changed
+10
-12
builtin-pack-objects.c
+9
-11
@@ -445,13 +445,9 @@ static int write_one(struct sha1file *f,
445
if (e->idx.offset || e->preferred_base)
446
return -1;
447
448
- /*
449
- * If we are deltified, attempt to write out base object first.
450
- * If that fails due to the pack size limit then the current
451
- * object might still possibly fit undeltified within that limit.
452
- */
453
- if (e->delta)
454
- write_one(f, e->delta, offset);
448
+ /* if we are deltified, write out base object first. */
449
+ if (e->delta && !write_one(f, e->delta, offset))
450
+ return 0;
451
452
e->idx.offset = *offset;
453
size = write_object(f, e, *offset);
@@ -505,9 +501,11 @@ static void write_pack_file(void)
501
sha1write(f, &hdr, sizeof(hdr));
502
offset = sizeof(hdr);
503
nr_written = 0;
508
- for (i = 0; i < nr_objects; i++)
509
- if (write_one(f, objects + i, &offset) == 1)
510
- display_progress(progress_state, written);
504
+ for (; i < nr_objects; i++) {
505
+ if (!write_one(f, objects + i, &offset))
506
+ break;
507
+ display_progress(progress_state, written);
508
+ }
509
510
/*
511
* Did we write the wrong # entries in the header?
@@ -582,7 +580,7 @@ static void write_pack_file(void)
580
written_list[j]->offset = (off_t)-1;
581
}
582
nr_remaining -= nr_written;
585
- } while (nr_remaining);
583
+ } while (nr_remaining && i < nr_objects);
584
585
free(written_list);
586
stop_progress(&progress_state);
t/t5300-pack-object.sh
+1
-1
@@ -389,7 +389,7 @@ test_expect_success 'verify resulting packs' '
389
test_expect_success 'tolerate packsizelimit smaller than biggest object' '
390
git config pack.packSizeLimit 1 &&
391
packname_11=$(git pack-objects test-11 <obj-list) &&
392
- test 3 = $(ls test-11-*.pack | wc -l)
392
+ test 5 = $(ls test-11-*.pack | wc -l)
393
'
394
395
test_expect_success 'verify resulting packs' '