Merge branch 'bc/hash-independent-tests-part-6'
[git] / t / t5319-multi-pack-index.sh
1 #!/bin/sh
2
3 test_description='multi-pack-indexes'
4 . ./test-lib.sh
5
6 objdir=.git/objects
7
8 midx_read_expect () {
9         NUM_PACKS=$1
10         NUM_OBJECTS=$2
11         NUM_CHUNKS=$3
12         OBJECT_DIR=$4
13         EXTRA_CHUNKS="$5"
14         {
15                 cat <<-EOF &&
16                 header: 4d494458 1 $NUM_CHUNKS $NUM_PACKS
17                 chunks: pack-names oid-fanout oid-lookup object-offsets$EXTRA_CHUNKS
18                 num_objects: $NUM_OBJECTS
19                 packs:
20                 EOF
21                 if test $NUM_PACKS -ge 1
22                 then
23                         ls $OBJECT_DIR/pack/ | grep idx | sort
24                 fi &&
25                 printf "object-dir: $OBJECT_DIR\n"
26         } >expect &&
27         test-tool read-midx $OBJECT_DIR >actual &&
28         test_cmp expect actual
29 }
30
31 test_expect_success 'write midx with no packs' '
32         test_when_finished rm -f pack/multi-pack-index &&
33         git multi-pack-index --object-dir=. write &&
34         midx_read_expect 0 0 4 .
35 '
36
37 generate_objects () {
38         i=$1
39         iii=$(printf '%03i' $i)
40         {
41                 test-tool genrandom "bar" 200 &&
42                 test-tool genrandom "baz $iii" 50
43         } >wide_delta_$iii &&
44         {
45                 test-tool genrandom "foo"$i 100 &&
46                 test-tool genrandom "foo"$(( $i + 1 )) 100 &&
47                 test-tool genrandom "foo"$(( $i + 2 )) 100
48         } >deep_delta_$iii &&
49         {
50                 echo $iii &&
51                 test-tool genrandom "$iii" 8192
52         } >file_$iii &&
53         git update-index --add file_$iii deep_delta_$iii wide_delta_$iii
54 }
55
56 commit_and_list_objects () {
57         {
58                 echo 101 &&
59                 test-tool genrandom 100 8192;
60         } >file_101 &&
61         git update-index --add file_101 &&
62         tree=$(git write-tree) &&
63         commit=$(git commit-tree $tree -p HEAD</dev/null) &&
64         {
65                 echo $tree &&
66                 git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\)        .*/\\1/"
67         } >obj-list &&
68         git reset --hard $commit
69 }
70
71 test_expect_success 'create objects' '
72         test_commit initial &&
73         for i in $(test_seq 1 5)
74         do
75                 generate_objects $i
76         done &&
77         commit_and_list_objects
78 '
79
80 test_expect_success 'write midx with one v1 pack' '
81         pack=$(git pack-objects --index-version=1 $objdir/pack/test <obj-list) &&
82         test_when_finished rm $objdir/pack/test-$pack.pack \
83                 $objdir/pack/test-$pack.idx $objdir/pack/multi-pack-index &&
84         git multi-pack-index --object-dir=$objdir write &&
85         midx_read_expect 1 18 4 $objdir
86 '
87
88 midx_git_two_modes () {
89         git -c core.multiPackIndex=false $1 >expect &&
90         git -c core.multiPackIndex=true $1 >actual &&
91         if [ "$2" = "sorted" ]
92         then
93                 sort <expect >expect.sorted &&
94                 mv expect.sorted expect &&
95                 sort <actual >actual.sorted &&
96                 mv actual.sorted actual
97         fi &&
98         test_cmp expect actual
99 }
100
101 compare_results_with_midx () {
102         MSG=$1
103         test_expect_success "check normal git operations: $MSG" '
104                 midx_git_two_modes "rev-list --objects --all" &&
105                 midx_git_two_modes "log --raw" &&
106                 midx_git_two_modes "count-objects --verbose" &&
107                 midx_git_two_modes "cat-file --batch-all-objects --batch-check" &&
108                 midx_git_two_modes "cat-file --batch-all-objects --batch-check --unordered" sorted
109         '
110 }
111
112 test_expect_success 'write midx with one v2 pack' '
113         git pack-objects --index-version=2,0x40 $objdir/pack/test <obj-list &&
114         git multi-pack-index --object-dir=$objdir write &&
115         midx_read_expect 1 18 4 $objdir
116 '
117
118 compare_results_with_midx "one v2 pack"
119
120 test_expect_success 'corrupt idx not opened' '
121         idx=$(test-tool read-midx $objdir | grep "\.idx\$") &&
122         mv $objdir/pack/$idx backup-$idx &&
123         test_when_finished "mv backup-\$idx \$objdir/pack/\$idx" &&
124
125         # This is the minimum size for a sha-1 based .idx; this lets
126         # us pass perfunctory tests, but anything that actually opens and reads
127         # the idx file will complain.
128         test_copy_bytes 1064 <backup-$idx >$objdir/pack/$idx &&
129
130         git -c core.multiPackIndex=true rev-list --objects --all 2>err &&
131         test_must_be_empty err
132 '
133
134 test_expect_success 'add more objects' '
135         for i in $(test_seq 6 10)
136         do
137                 generate_objects $i
138         done &&
139         commit_and_list_objects
140 '
141
142 test_expect_success 'write midx with two packs' '
143         git pack-objects --index-version=1 $objdir/pack/test-2 <obj-list &&
144         git multi-pack-index --object-dir=$objdir write &&
145         midx_read_expect 2 34 4 $objdir
146 '
147
148 compare_results_with_midx "two packs"
149
150 test_expect_success 'write progress off for redirected stderr' '
151         git multi-pack-index --object-dir=$objdir write 2>err &&
152         test_line_count = 0 err
153 '
154
155 test_expect_success 'write force progress on for stderr' '
156         git multi-pack-index --object-dir=$objdir --progress write 2>err &&
157         test_file_not_empty err
158 '
159
160 test_expect_success 'write with the --no-progress option' '
161         git multi-pack-index --object-dir=$objdir --no-progress write 2>err &&
162         test_line_count = 0 err
163 '
164
165 test_expect_success 'add more packs' '
166         for j in $(test_seq 11 20)
167         do
168                 generate_objects $j &&
169                 commit_and_list_objects &&
170                 git pack-objects --index-version=2 $objdir/pack/test-pack <obj-list
171         done
172 '
173
174 compare_results_with_midx "mixed mode (two packs + extra)"
175
176 test_expect_success 'write midx with twelve packs' '
177         git multi-pack-index --object-dir=$objdir write &&
178         midx_read_expect 12 74 4 $objdir
179 '
180
181 compare_results_with_midx "twelve packs"
182
183 test_expect_success 'verify multi-pack-index success' '
184         git multi-pack-index verify --object-dir=$objdir
185 '
186
187 test_expect_success 'verify progress off for redirected stderr' '
188         git multi-pack-index verify --object-dir=$objdir 2>err &&
189         test_line_count = 0 err
190 '
191
192 test_expect_success 'verify force progress on for stderr' '
193         git multi-pack-index verify --object-dir=$objdir --progress 2>err &&
194         test_file_not_empty err
195 '
196
197 test_expect_success 'verify with the --no-progress option' '
198         git multi-pack-index verify --object-dir=$objdir --no-progress 2>err &&
199         test_line_count = 0 err
200 '
201
202 # usage: corrupt_midx_and_verify <pos> <data> <objdir> <string>
203 corrupt_midx_and_verify() {
204         POS=$1 &&
205         DATA="${2:-\0}" &&
206         OBJDIR=$3 &&
207         GREPSTR="$4" &&
208         COMMAND="$5" &&
209         if test -z "$COMMAND"
210         then
211                 COMMAND="git multi-pack-index verify --object-dir=$OBJDIR"
212         fi &&
213         FILE=$OBJDIR/pack/multi-pack-index &&
214         chmod a+w $FILE &&
215         test_when_finished mv midx-backup $FILE &&
216         cp $FILE midx-backup &&
217         printf "$DATA" | dd of="$FILE" bs=1 seek="$POS" conv=notrunc &&
218         test_must_fail $COMMAND 2>test_err &&
219         grep -v "^+" test_err >err &&
220         test_i18ngrep "$GREPSTR" err
221 }
222
223 test_expect_success 'verify bad signature' '
224         corrupt_midx_and_verify 0 "\00" $objdir \
225                 "multi-pack-index signature"
226 '
227
228 HASH_LEN=20
229 NUM_OBJECTS=74
230 MIDX_BYTE_VERSION=4
231 MIDX_BYTE_OID_VERSION=5
232 MIDX_BYTE_CHUNK_COUNT=6
233 MIDX_HEADER_SIZE=12
234 MIDX_BYTE_CHUNK_ID=$MIDX_HEADER_SIZE
235 MIDX_BYTE_CHUNK_OFFSET=$(($MIDX_HEADER_SIZE + 4))
236 MIDX_NUM_CHUNKS=5
237 MIDX_CHUNK_LOOKUP_WIDTH=12
238 MIDX_OFFSET_PACKNAMES=$(($MIDX_HEADER_SIZE + \
239                          $MIDX_NUM_CHUNKS * $MIDX_CHUNK_LOOKUP_WIDTH))
240 MIDX_BYTE_PACKNAME_ORDER=$(($MIDX_OFFSET_PACKNAMES + 2))
241 MIDX_OFFSET_OID_FANOUT=$(($MIDX_OFFSET_PACKNAMES + 652))
242 MIDX_OID_FANOUT_WIDTH=4
243 MIDX_BYTE_OID_FANOUT_ORDER=$((MIDX_OFFSET_OID_FANOUT + 250 * $MIDX_OID_FANOUT_WIDTH + 1))
244 MIDX_OFFSET_OID_LOOKUP=$(($MIDX_OFFSET_OID_FANOUT + 256 * $MIDX_OID_FANOUT_WIDTH))
245 MIDX_BYTE_OID_LOOKUP=$(($MIDX_OFFSET_OID_LOOKUP + 16 * $HASH_LEN))
246 MIDX_OFFSET_OBJECT_OFFSETS=$(($MIDX_OFFSET_OID_LOOKUP + $NUM_OBJECTS * $HASH_LEN))
247 MIDX_OFFSET_WIDTH=8
248 MIDX_BYTE_PACK_INT_ID=$(($MIDX_OFFSET_OBJECT_OFFSETS + 16 * $MIDX_OFFSET_WIDTH + 2))
249 MIDX_BYTE_OFFSET=$(($MIDX_OFFSET_OBJECT_OFFSETS + 16 * $MIDX_OFFSET_WIDTH + 6))
250
251 test_expect_success 'verify bad version' '
252         corrupt_midx_and_verify $MIDX_BYTE_VERSION "\00" $objdir \
253                 "multi-pack-index version"
254 '
255
256 test_expect_success 'verify bad OID version' '
257         corrupt_midx_and_verify $MIDX_BYTE_OID_VERSION "\02" $objdir \
258                 "hash version"
259 '
260
261 test_expect_success 'verify truncated chunk count' '
262         corrupt_midx_and_verify $MIDX_BYTE_CHUNK_COUNT "\01" $objdir \
263                 "missing required"
264 '
265
266 test_expect_success 'verify extended chunk count' '
267         corrupt_midx_and_verify $MIDX_BYTE_CHUNK_COUNT "\07" $objdir \
268                 "terminating multi-pack-index chunk id appears earlier than expected"
269 '
270
271 test_expect_success 'verify missing required chunk' '
272         corrupt_midx_and_verify $MIDX_BYTE_CHUNK_ID "\01" $objdir \
273                 "missing required"
274 '
275
276 test_expect_success 'verify invalid chunk offset' '
277         corrupt_midx_and_verify $MIDX_BYTE_CHUNK_OFFSET "\01" $objdir \
278                 "invalid chunk offset (too large)"
279 '
280
281 test_expect_success 'verify packnames out of order' '
282         corrupt_midx_and_verify $MIDX_BYTE_PACKNAME_ORDER "z" $objdir \
283                 "pack names out of order"
284 '
285
286 test_expect_success 'verify packnames out of order' '
287         corrupt_midx_and_verify $MIDX_BYTE_PACKNAME_ORDER "a" $objdir \
288                 "failed to load pack"
289 '
290
291 test_expect_success 'verify oid fanout out of order' '
292         corrupt_midx_and_verify $MIDX_BYTE_OID_FANOUT_ORDER "\01" $objdir \
293                 "oid fanout out of order"
294 '
295
296 test_expect_success 'verify oid lookup out of order' '
297         corrupt_midx_and_verify $MIDX_BYTE_OID_LOOKUP "\00" $objdir \
298                 "oid lookup out of order"
299 '
300
301 test_expect_success 'verify incorrect pack-int-id' '
302         corrupt_midx_and_verify $MIDX_BYTE_PACK_INT_ID "\07" $objdir \
303                 "bad pack-int-id"
304 '
305
306 test_expect_success 'verify incorrect offset' '
307         corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\07" $objdir \
308                 "incorrect object offset"
309 '
310
311 test_expect_success 'git-fsck incorrect offset' '
312         corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\07" $objdir \
313                 "incorrect object offset" \
314                 "git -c core.multipackindex=true fsck"
315 '
316
317 test_expect_success 'repack progress off for redirected stderr' '
318         git multi-pack-index --object-dir=$objdir repack 2>err &&
319         test_line_count = 0 err
320 '
321
322 test_expect_success 'repack force progress on for stderr' '
323         git multi-pack-index --object-dir=$objdir --progress repack 2>err &&
324         test_file_not_empty err
325 '
326
327 test_expect_success 'repack with the --no-progress option' '
328         git multi-pack-index --object-dir=$objdir --no-progress repack 2>err &&
329         test_line_count = 0 err
330 '
331
332 test_expect_success 'repack removes multi-pack-index' '
333         test_path_is_file $objdir/pack/multi-pack-index &&
334         GIT_TEST_MULTI_PACK_INDEX=0 git repack -adf &&
335         test_path_is_missing $objdir/pack/multi-pack-index
336 '
337
338 compare_results_with_midx "after repack"
339
340 test_expect_success 'multi-pack-index and pack-bitmap' '
341         git -c repack.writeBitmaps=true repack -ad &&
342         git multi-pack-index write &&
343         git rev-list --test-bitmap HEAD
344 '
345
346 test_expect_success 'multi-pack-index and alternates' '
347         git init --bare alt.git &&
348         echo $(pwd)/alt.git/objects >.git/objects/info/alternates &&
349         echo content1 >file1 &&
350         altblob=$(GIT_DIR=alt.git git hash-object -w file1) &&
351         git cat-file blob $altblob &&
352         git rev-list --all
353 '
354
355 compare_results_with_midx "with alternate (local midx)"
356
357 test_expect_success 'multi-pack-index in an alternate' '
358         mv .git/objects/pack/* alt.git/objects/pack &&
359         test_commit add_local_objects &&
360         git repack --local &&
361         git multi-pack-index write &&
362         midx_read_expect 1 3 4 $objdir &&
363         git reset --hard HEAD~1 &&
364         rm -f .git/objects/pack/*
365 '
366
367 compare_results_with_midx "with alternate (remote midx)"
368
369 # usage: corrupt_data <file> <pos> [<data>]
370 corrupt_data () {
371         file=$1
372         pos=$2
373         data="${3:-\0}"
374         printf "$data" | dd of="$file" bs=1 seek="$pos" conv=notrunc
375 }
376
377 # Force 64-bit offsets by manipulating the idx file.
378 # This makes the IDX file _incorrect_ so be careful to clean up after!
379 test_expect_success 'force some 64-bit offsets with pack-objects' '
380         mkdir objects64 &&
381         mkdir objects64/pack &&
382         for i in $(test_seq 1 11)
383         do
384                 generate_objects 11
385         done &&
386         commit_and_list_objects &&
387         pack64=$(git pack-objects --index-version=2,0x40 objects64/pack/test-64 <obj-list) &&
388         idx64=objects64/pack/test-64-$pack64.idx &&
389         chmod u+w $idx64 &&
390         corrupt_data $idx64 2999 "\02" &&
391         midx64=$(git multi-pack-index --object-dir=objects64 write) &&
392         midx_read_expect 1 63 5 objects64 " large-offsets"
393 '
394
395 test_expect_success 'verify multi-pack-index with 64-bit offsets' '
396         git multi-pack-index verify --object-dir=objects64
397 '
398
399 NUM_OBJECTS=63
400 MIDX_OFFSET_OID_FANOUT=$((MIDX_OFFSET_PACKNAMES + 54))
401 MIDX_OFFSET_OID_LOOKUP=$((MIDX_OFFSET_OID_FANOUT + 256 * $MIDX_OID_FANOUT_WIDTH))
402 MIDX_OFFSET_OBJECT_OFFSETS=$(($MIDX_OFFSET_OID_LOOKUP + $NUM_OBJECTS * $HASH_LEN))
403 MIDX_OFFSET_LARGE_OFFSETS=$(($MIDX_OFFSET_OBJECT_OFFSETS + $NUM_OBJECTS * $MIDX_OFFSET_WIDTH))
404 MIDX_BYTE_LARGE_OFFSET=$(($MIDX_OFFSET_LARGE_OFFSETS + 3))
405
406 test_expect_success 'verify incorrect 64-bit offset' '
407         corrupt_midx_and_verify $MIDX_BYTE_LARGE_OFFSET "\07" objects64 \
408                 "incorrect object offset"
409 '
410
411 test_expect_success 'setup expire tests' '
412         mkdir dup &&
413         (
414                 cd dup &&
415                 git init &&
416                 test-tool genrandom "data" 4096 >large_file.txt &&
417                 git update-index --add large_file.txt &&
418                 for i in $(test_seq 1 20)
419                 do
420                         test_commit $i
421                 done &&
422                 git branch A HEAD &&
423                 git branch B HEAD~8 &&
424                 git branch C HEAD~13 &&
425                 git branch D HEAD~16 &&
426                 git branch E HEAD~18 &&
427                 git pack-objects --revs .git/objects/pack/pack-A <<-EOF &&
428                 refs/heads/A
429                 ^refs/heads/B
430                 EOF
431                 git pack-objects --revs .git/objects/pack/pack-B <<-EOF &&
432                 refs/heads/B
433                 ^refs/heads/C
434                 EOF
435                 git pack-objects --revs .git/objects/pack/pack-C <<-EOF &&
436                 refs/heads/C
437                 ^refs/heads/D
438                 EOF
439                 git pack-objects --revs .git/objects/pack/pack-D <<-EOF &&
440                 refs/heads/D
441                 ^refs/heads/E
442                 EOF
443                 git pack-objects --revs .git/objects/pack/pack-E <<-EOF &&
444                 refs/heads/E
445                 EOF
446                 git multi-pack-index write &&
447                 cp -r .git/objects/pack .git/objects/pack-backup
448         )
449 '
450
451 test_expect_success 'expire does not remove any packs' '
452         (
453                 cd dup &&
454                 ls .git/objects/pack >expect &&
455                 git multi-pack-index expire &&
456                 ls .git/objects/pack >actual &&
457                 test_cmp expect actual
458         )
459 '
460
461 test_expect_success 'expire progress off for redirected stderr' '
462         (
463                 cd dup &&
464                 git multi-pack-index expire 2>err &&
465                 test_line_count = 0 err
466         )
467 '
468
469 test_expect_success 'expire force progress on for stderr' '
470         (
471                 cd dup &&
472                 git multi-pack-index --progress expire 2>err &&
473                 test_file_not_empty err
474         )
475 '
476
477 test_expect_success 'expire with the --no-progress option' '
478         (
479                 cd dup &&
480                 git multi-pack-index --no-progress expire 2>err &&
481                 test_line_count = 0 err
482         )
483 '
484
485 test_expect_success 'expire removes unreferenced packs' '
486         (
487                 cd dup &&
488                 git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
489                 refs/heads/A
490                 ^refs/heads/C
491                 EOF
492                 git multi-pack-index write &&
493                 ls .git/objects/pack | grep -v -e pack-[AB] >expect &&
494                 git multi-pack-index expire &&
495                 ls .git/objects/pack >actual &&
496                 test_cmp expect actual &&
497                 ls .git/objects/pack/ | grep idx >expect-idx &&
498                 test-tool read-midx .git/objects | grep idx >actual-midx &&
499                 test_cmp expect-idx actual-midx &&
500                 git multi-pack-index verify &&
501                 git fsck
502         )
503 '
504
505 test_expect_success 'repack with minimum size does not alter existing packs' '
506         (
507                 cd dup &&
508                 rm -rf .git/objects/pack &&
509                 mv .git/objects/pack-backup .git/objects/pack &&
510                 touch -m -t 201901010000 .git/objects/pack/pack-D* &&
511                 touch -m -t 201901010001 .git/objects/pack/pack-C* &&
512                 touch -m -t 201901010002 .git/objects/pack/pack-B* &&
513                 touch -m -t 201901010003 .git/objects/pack/pack-A* &&
514                 ls .git/objects/pack >expect &&
515                 MINSIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 1) &&
516                 git multi-pack-index repack --batch-size=$MINSIZE &&
517                 ls .git/objects/pack >actual &&
518                 test_cmp expect actual
519         )
520 '
521
522 test_expect_success 'repack creates a new pack' '
523         (
524                 cd dup &&
525                 ls .git/objects/pack/*idx >idx-list &&
526                 test_line_count = 5 idx-list &&
527                 THIRD_SMALLEST_SIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 3 | tail -n 1) &&
528                 BATCH_SIZE=$(($THIRD_SMALLEST_SIZE + 1)) &&
529                 git multi-pack-index repack --batch-size=$BATCH_SIZE &&
530                 ls .git/objects/pack/*idx >idx-list &&
531                 test_line_count = 6 idx-list &&
532                 test-tool read-midx .git/objects | grep idx >midx-list &&
533                 test_line_count = 6 midx-list
534         )
535 '
536
537 test_expect_success 'expire removes repacked packs' '
538         (
539                 cd dup &&
540                 ls -al .git/objects/pack/*pack &&
541                 ls -S .git/objects/pack/*pack | head -n 4 >expect &&
542                 git multi-pack-index expire &&
543                 ls -S .git/objects/pack/*pack >actual &&
544                 test_cmp expect actual &&
545                 test-tool read-midx .git/objects | grep idx >midx-list &&
546                 test_line_count = 4 midx-list
547         )
548 '
549
550 test_expect_success 'expire works when adding new packs' '
551         (
552                 cd dup &&
553                 git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
554                 refs/heads/A
555                 ^refs/heads/B
556                 EOF
557                 git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
558                 refs/heads/B
559                 ^refs/heads/C
560                 EOF
561                 git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
562                 refs/heads/C
563                 ^refs/heads/D
564                 EOF
565                 git multi-pack-index write &&
566                 git pack-objects --revs .git/objects/pack/a-pack <<-EOF &&
567                 refs/heads/D
568                 ^refs/heads/E
569                 EOF
570                 git multi-pack-index write &&
571                 git pack-objects --revs .git/objects/pack/z-pack <<-EOF &&
572                 refs/heads/E
573                 EOF
574                 git multi-pack-index expire &&
575                 ls .git/objects/pack/ | grep idx >expect &&
576                 test-tool read-midx .git/objects | grep idx >actual &&
577                 test_cmp expect actual &&
578                 git multi-pack-index verify
579         )
580 '
581
582 test_expect_success 'expire respects .keep files' '
583         (
584                 cd dup &&
585                 git pack-objects --revs .git/objects/pack/pack-all <<-EOF &&
586                 refs/heads/A
587                 EOF
588                 git multi-pack-index write &&
589                 PACKA=$(ls .git/objects/pack/a-pack*\.pack | sed s/\.pack\$//) &&
590                 touch $PACKA.keep &&
591                 git multi-pack-index expire &&
592                 ls -S .git/objects/pack/a-pack* | grep $PACKA >a-pack-files &&
593                 test_line_count = 3 a-pack-files &&
594                 test-tool read-midx .git/objects | grep idx >midx-list &&
595                 test_line_count = 2 midx-list
596         )
597 '
598
599 test_expect_success 'repack --batch-size=0 repacks everything' '
600         (
601                 cd dup &&
602                 rm .git/objects/pack/*.keep &&
603                 ls .git/objects/pack/*idx >idx-list &&
604                 test_line_count = 2 idx-list &&
605                 git multi-pack-index repack --batch-size=0 &&
606                 ls .git/objects/pack/*idx >idx-list &&
607                 test_line_count = 3 idx-list &&
608                 test-tool read-midx .git/objects | grep idx >midx-list &&
609                 test_line_count = 3 midx-list &&
610                 git multi-pack-index expire &&
611                 ls -al .git/objects/pack/*idx >idx-list &&
612                 test_line_count = 1 idx-list &&
613                 git multi-pack-index repack --batch-size=0 &&
614                 ls -al .git/objects/pack/*idx >new-idx-list &&
615                 test_cmp idx-list new-idx-list
616         )
617 '
618
619 test_done