Skip to content

Commit

Permalink
Revert "pack-objects: fix pack generation when using pack_size_limit"
Browse files Browse the repository at this point in the history
This reverts most of commit a2430dd.

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>
  • Loading branch information
Nicolas Pitre authored and Junio C Hamano committed Feb 8, 2010
1 parent 8051a03 commit 720c9f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,9 @@ static int write_one(struct sha1file *f,
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);
Expand Down Expand Up @@ -505,9 +501,11 @@ static void write_pack_file(void)
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?
Expand Down Expand Up @@ -582,7 +580,7 @@ static void write_pack_file(void)
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);
Expand Down
2 changes: 1 addition & 1 deletion t/t5300-pack-object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ test_expect_success 'verify resulting packs' '
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' '
Expand Down

0 comments on commit 720c9f7

Please sign in to comment.