Skip to content

Commit 9e8c754

Browse files
committed
Merge branch 'ds/midx-repack-to-batch-size'
The "--batch-size" option of "git multi-pack-index repack" command is now used to specify that very small packfiles are collected into one until the total size roughly exceeds it. * ds/midx-repack-to-batch-size: multi-pack-index: repack batches below --batch-size
2 parents a654836 + 1eb22c7 commit 9e8c754

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

Documentation/git-multi-pack-index.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ repack::
5151
multi-pack-index, then divide by the total number of objects in
5252
the pack and multiply by the pack size. We select packs with
5353
expected size below the batch size until the set of packs have
54-
total expected size at least the batch size. If the total size
55-
does not reach the batch size, then do nothing. If a new pack-
56-
file is created, rewrite the multi-pack-index to reference the
57-
new pack-file. A later run of 'git multi-pack-index expire' will
58-
delete the pack-files that were part of this batch.
54+
total expected size at least the batch size, or all pack-files
55+
are considered. If only one pack-file is selected, then do
56+
nothing. If a new pack-file is created, rewrite the
57+
multi-pack-index to reference the new pack-file. A later run of
58+
'git multi-pack-index expire' will delete the pack-files that
59+
were part of this batch.
5960
+
6061
If `repack.packKeptObjects` is `false`, then any pack-files with an
6162
associated `.keep` file will not be selected for the batch to repack.

midx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ static int fill_included_packs_batch(struct repository *r,
13941394

13951395
free(pack_info);
13961396

1397-
if (total_size < batch_size || packs_to_repack < 2)
1397+
if (packs_to_repack < 2)
13981398
return 1;
13991399

14001400
return 0;

t/t5319-multi-pack-index.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ test_expect_success 'expire respects .keep files' '
677677
'
678678

679679
test_expect_success 'repack --batch-size=0 repacks everything' '
680+
cp -r dup dup2 &&
680681
(
681682
cd dup &&
682683
rm .git/objects/pack/*.keep &&
@@ -696,4 +697,21 @@ test_expect_success 'repack --batch-size=0 repacks everything' '
696697
)
697698
'
698699

700+
test_expect_success 'repack --batch-size=<large> repacks everything' '
701+
(
702+
cd dup2 &&
703+
rm .git/objects/pack/*.keep &&
704+
ls .git/objects/pack/*idx >idx-list &&
705+
test_line_count = 2 idx-list &&
706+
git multi-pack-index repack --batch-size=2000000 &&
707+
ls .git/objects/pack/*idx >idx-list &&
708+
test_line_count = 3 idx-list &&
709+
test-tool read-midx .git/objects | grep idx >midx-list &&
710+
test_line_count = 3 midx-list &&
711+
git multi-pack-index expire &&
712+
ls -al .git/objects/pack/*idx >idx-list &&
713+
test_line_count = 1 idx-list
714+
)
715+
'
716+
699717
test_done

0 commit comments

Comments
 (0)