]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5319-multi-pack-index.sh
Merge branch 'wb/midx-progress'
[thirdparty/git.git] / t / t5319-multi-pack-index.sh
CommitLineData
a3407730
DS
1#!/bin/sh
2
3test_description='multi-pack-indexes'
4. ./test-lib.sh
5
c4d25228
DS
6objdir=.git/objects
7
4d80560c 8midx_read_expect () {
396f2570 9 NUM_PACKS=$1
d7cacf29 10 NUM_OBJECTS=$2
662148c4
DS
11 NUM_CHUNKS=$3
12 OBJECT_DIR=$4
13 EXTRA_CHUNKS="$5"
3227565c
DS
14 {
15 cat <<-EOF &&
662148c4
DS
16 header: 4d494458 1 $NUM_CHUNKS $NUM_PACKS
17 chunks: pack-names oid-fanout oid-lookup object-offsets$EXTRA_CHUNKS
d7cacf29 18 num_objects: $NUM_OBJECTS
3227565c
DS
19 packs:
20 EOF
21 if test $NUM_PACKS -ge 1
22 then
662148c4 23 ls $OBJECT_DIR/pack/ | grep idx | sort
3227565c 24 fi &&
662148c4 25 printf "object-dir: $OBJECT_DIR\n"
3227565c 26 } >expect &&
662148c4 27 test-tool read-midx $OBJECT_DIR >actual &&
4d80560c
DS
28 test_cmp expect actual
29}
30
a3407730 31test_expect_success 'write midx with no packs' '
fc59e748
DS
32 test_when_finished rm -f pack/multi-pack-index &&
33 git multi-pack-index --object-dir=. write &&
662148c4 34 midx_read_expect 0 0 4 .
a3407730
DS
35'
36
2c381335
DS
37generate_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
56commit_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
71test_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
80test_expect_success 'write midx with one v1 pack' '
c4d25228
DS
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
2c381335
DS
86'
87
c4d25228 88midx_git_two_modes () {
b4a14394
JK
89 git -c core.multiPackIndex=false $1 >expect &&
90 git -c core.multiPackIndex=true $1 >actual &&
e9ab2ed7
DS
91 if [ "$2" = "sorted" ]
92 then
b4a14394
JK
93 sort <expect >expect.sorted &&
94 mv expect.sorted expect &&
95 sort <actual >actual.sorted &&
96 mv actual.sorted actual
e9ab2ed7 97 fi &&
c4d25228
DS
98 test_cmp expect actual
99}
100
101compare_results_with_midx () {
102 MSG=$1
103 test_expect_success "check normal git operations: $MSG" '
104 midx_git_two_modes "rev-list --objects --all" &&
e9ab2ed7
DS
105 midx_git_two_modes "log --raw" &&
106 midx_git_two_modes "count-objects --verbose" &&
5670ad98
JK
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
c4d25228
DS
109 '
110}
111
2c381335 112test_expect_success 'write midx with one v2 pack' '
c4d25228
DS
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
2c381335
DS
116'
117
c4d25228
DS
118compare_results_with_midx "one v2 pack"
119
fc789156
JK
120test_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
2c381335
DS
134test_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
142test_expect_success 'write midx with two packs' '
c4d25228
DS
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
2c381335
DS
146'
147
c4d25228
DS
148compare_results_with_midx "two packs"
149
680cba2c
WB
150test_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
155test_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
160test_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
2c381335
DS
165test_expect_success 'add more packs' '
166 for j in $(test_seq 11 20)
167 do
168 generate_objects $j &&
169 commit_and_list_objects &&
c4d25228 170 git pack-objects --index-version=2 $objdir/pack/test-pack <obj-list
2c381335
DS
171 done
172'
173
c4d25228
DS
174compare_results_with_midx "mixed mode (two packs + extra)"
175
2c381335 176test_expect_success 'write midx with twelve packs' '
c4d25228
DS
177 git multi-pack-index --object-dir=$objdir write &&
178 midx_read_expect 12 74 4 $objdir
662148c4
DS
179'
180
c4d25228
DS
181compare_results_with_midx "twelve packs"
182
56ee7ff1
DS
183test_expect_success 'verify multi-pack-index success' '
184 git multi-pack-index verify --object-dir=$objdir
185'
186
680cba2c
WB
187test_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
192test_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
197test_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
53ad0407
DS
202# usage: corrupt_midx_and_verify <pos> <data> <objdir> <string>
203corrupt_midx_and_verify() {
204 POS=$1 &&
205 DATA="${2:-\0}" &&
206 OBJDIR=$3 &&
207 GREPSTR="$4" &&
66ec0390
DS
208 COMMAND="$5" &&
209 if test -z "$COMMAND"
210 then
211 COMMAND="git multi-pack-index verify --object-dir=$OBJDIR"
212 fi &&
53ad0407
DS
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 &&
66ec0390 218 test_must_fail $COMMAND 2>test_err &&
53ad0407
DS
219 grep -v "^+" test_err >err &&
220 test_i18ngrep "$GREPSTR" err
221}
222
223test_expect_success 'verify bad signature' '
224 corrupt_midx_and_verify 0 "\00" $objdir \
225 "multi-pack-index signature"
226'
227
55c5648d 228HASH_LEN=20
cc6af73c 229NUM_OBJECTS=74
53ad0407
DS
230MIDX_BYTE_VERSION=4
231MIDX_BYTE_OID_VERSION=5
232MIDX_BYTE_CHUNK_COUNT=6
d3f8e211
DS
233MIDX_HEADER_SIZE=12
234MIDX_BYTE_CHUNK_ID=$MIDX_HEADER_SIZE
235MIDX_BYTE_CHUNK_OFFSET=$(($MIDX_HEADER_SIZE + 4))
8e72a3c3
DS
236MIDX_NUM_CHUNKS=5
237MIDX_CHUNK_LOOKUP_WIDTH=12
238MIDX_OFFSET_PACKNAMES=$(($MIDX_HEADER_SIZE + \
239 $MIDX_NUM_CHUNKS * $MIDX_CHUNK_LOOKUP_WIDTH))
240MIDX_BYTE_PACKNAME_ORDER=$(($MIDX_OFFSET_PACKNAMES + 2))
2f23d3f3
DS
241MIDX_OFFSET_OID_FANOUT=$(($MIDX_OFFSET_PACKNAMES + 652))
242MIDX_OID_FANOUT_WIDTH=4
243MIDX_BYTE_OID_FANOUT_ORDER=$((MIDX_OFFSET_OID_FANOUT + 250 * $MIDX_OID_FANOUT_WIDTH + 1))
55c5648d
DS
244MIDX_OFFSET_OID_LOOKUP=$(($MIDX_OFFSET_OID_FANOUT + 256 * $MIDX_OID_FANOUT_WIDTH))
245MIDX_BYTE_OID_LOOKUP=$(($MIDX_OFFSET_OID_LOOKUP + 16 * $HASH_LEN))
cc6af73c
DS
246MIDX_OFFSET_OBJECT_OFFSETS=$(($MIDX_OFFSET_OID_LOOKUP + $NUM_OBJECTS * $HASH_LEN))
247MIDX_OFFSET_WIDTH=8
248MIDX_BYTE_PACK_INT_ID=$(($MIDX_OFFSET_OBJECT_OFFSETS + 16 * $MIDX_OFFSET_WIDTH + 2))
249MIDX_BYTE_OFFSET=$(($MIDX_OFFSET_OBJECT_OFFSETS + 16 * $MIDX_OFFSET_WIDTH + 6))
53ad0407
DS
250
251test_expect_success 'verify bad version' '
252 corrupt_midx_and_verify $MIDX_BYTE_VERSION "\00" $objdir \
253 "multi-pack-index version"
254'
255
256test_expect_success 'verify bad OID version' '
257 corrupt_midx_and_verify $MIDX_BYTE_OID_VERSION "\02" $objdir \
258 "hash version"
259'
260
261test_expect_success 'verify truncated chunk count' '
262 corrupt_midx_and_verify $MIDX_BYTE_CHUNK_COUNT "\01" $objdir \
263 "missing required"
264'
265
266test_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
d3f8e211
DS
271test_expect_success 'verify missing required chunk' '
272 corrupt_midx_and_verify $MIDX_BYTE_CHUNK_ID "\01" $objdir \
273 "missing required"
274'
275
276test_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
8e72a3c3
DS
281test_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
d4bf1d88
DS
286test_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
2f23d3f3
DS
291test_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
55c5648d
DS
296test_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
cc6af73c
DS
301test_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
306test_expect_success 'verify incorrect offset' '
307 corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\07" $objdir \
308 "incorrect object offset"
309'
310
66ec0390
DS
311test_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
680cba2c
WB
317test_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
322test_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
327test_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
525e18c0
DS
332test_expect_success 'repack removes multi-pack-index' '
333 test_path_is_file $objdir/pack/multi-pack-index &&
0465a505 334 GIT_TEST_MULTI_PACK_INDEX=0 git repack -adf &&
525e18c0
DS
335 test_path_is_missing $objdir/pack/multi-pack-index
336'
337
338compare_results_with_midx "after repack"
339
e9ab2ed7
DS
340test_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
29e2016b
DS
346test_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
355compare_results_with_midx "with alternate (local midx)"
356
357test_expect_success 'multi-pack-index in an alternate' '
6a22d521
DS
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/*
29e2016b
DS
365'
366
367compare_results_with_midx "with alternate (remote midx)"
368
662148c4
DS
369# usage: corrupt_data <file> <pos> [<data>]
370corrupt_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!
379test_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"
2c381335
DS
393'
394
56ee7ff1
DS
395test_expect_success 'verify multi-pack-index with 64-bit offsets' '
396 git multi-pack-index verify --object-dir=objects64
397'
398
cc6af73c
DS
399NUM_OBJECTS=63
400MIDX_OFFSET_OID_FANOUT=$((MIDX_OFFSET_PACKNAMES + 54))
401MIDX_OFFSET_OID_LOOKUP=$((MIDX_OFFSET_OID_FANOUT + 256 * $MIDX_OID_FANOUT_WIDTH))
402MIDX_OFFSET_OBJECT_OFFSETS=$(($MIDX_OFFSET_OID_LOOKUP + $NUM_OBJECTS * $HASH_LEN))
403MIDX_OFFSET_LARGE_OFFSETS=$(($MIDX_OFFSET_OBJECT_OFFSETS + $NUM_OBJECTS * $MIDX_OFFSET_WIDTH))
404MIDX_BYTE_LARGE_OFFSET=$(($MIDX_OFFSET_LARGE_OFFSETS + 3))
405
406test_expect_success 'verify incorrect 64-bit offset' '
407 corrupt_midx_and_verify $MIDX_BYTE_LARGE_OFFSET "\07" objects64 \
408 "incorrect object offset"
409'
410
cff97116
DS
411test_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
2af890bb
DS
446 git multi-pack-index write &&
447 cp -r .git/objects/pack .git/objects/pack-backup
cff97116
DS
448 )
449'
450
451test_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
680cba2c
WB
461test_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
469test_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
477test_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
19575c7c
DS
485test_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
2af890bb
DS
505test_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 &&
3612c233 515 MINSIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 1) &&
2af890bb
DS
516 git multi-pack-index repack --batch-size=$MINSIZE &&
517 ls .git/objects/pack >actual &&
518 test_cmp expect actual
519 )
520'
521
ce1e4a10
DS
522test_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 &&
3612c233 527 THIRD_SMALLEST_SIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 3 | tail -n 1) &&
ce1e4a10
DS
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
537test_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
d2743315
DS
550test_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
10bfa3f7
DS
582test_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
b526d8cb
DS
599test_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'
10bfa3f7 618
a3407730 619test_done