]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7700-repack.sh
rebase: allow overriding the maximal length of the generated labels
[thirdparty/git.git] / t / t7700-repack.sh
1 #!/bin/sh
2
3 test_description='git repack works correctly'
4
5 . ./test-lib.sh
6 . "${TEST_DIRECTORY}/lib-bitmap.sh"
7 . "${TEST_DIRECTORY}/lib-midx.sh"
8 . "${TEST_DIRECTORY}/lib-terminal.sh"
9
10 commit_and_pack () {
11 test_commit "$@" 1>&2 &&
12 incrpackid=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack </dev/null) &&
13 echo pack-${incrpackid}.pack
14 }
15
16 test_no_missing_in_packs () {
17 myidx=$(ls -1 .git/objects/pack/*.idx) &&
18 test_path_is_file "$myidx" &&
19 git verify-pack -v alt_objects/pack/*.idx >orig.raw &&
20 sed -n -e "s/^\($OID_REGEX\).*/\1/p" orig.raw | sort >orig &&
21 git verify-pack -v $myidx >dest.raw &&
22 cut -d" " -f1 dest.raw | sort >dest &&
23 comm -23 orig dest >missing &&
24 test_must_be_empty missing
25 }
26
27 # we expect $packid and $oid to be defined
28 test_has_duplicate_object () {
29 want_duplicate_object="$1"
30 found_duplicate_object=false
31 for p in .git/objects/pack/*.idx
32 do
33 idx=$(basename $p)
34 test "pack-$packid.idx" = "$idx" && continue
35 git verify-pack -v $p >packlist || return $?
36 if grep "^$oid" packlist
37 then
38 found_duplicate_object=true
39 echo "DUPLICATE OBJECT FOUND"
40 break
41 fi
42 done &&
43 test "$want_duplicate_object" = "$found_duplicate_object"
44 }
45
46 test_expect_success 'objects in packs marked .keep are not repacked' '
47 echo content1 >file1 &&
48 echo content2 >file2 &&
49 git add . &&
50 test_tick &&
51 git commit -m initial_commit &&
52 # Create two packs
53 # The first pack will contain all of the objects except one
54 git rev-list --objects --all >objs &&
55 grep -v file2 objs | git pack-objects pack &&
56 # The second pack will contain the excluded object
57 packid=$(grep file2 objs | git pack-objects pack) &&
58 >pack-$packid.keep &&
59 git verify-pack -v pack-$packid.idx >packlist &&
60 oid=$(head -n 1 packlist | sed -e "s/^\($OID_REGEX\).*/\1/") &&
61 mv pack-* .git/objects/pack/ &&
62 git repack -A -d -l &&
63 git prune-packed &&
64 test_has_duplicate_object false
65 '
66
67 test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' '
68 # build on $oid, $packid, and .keep state from previous
69 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 git repack -Adbl &&
70 test_has_duplicate_object true
71 '
72
73 test_expect_success 'writing bitmaps via config can duplicate .keep objects' '
74 # build on $oid, $packid, and .keep state from previous
75 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 \
76 git -c repack.writebitmaps=true repack -Adl &&
77 test_has_duplicate_object true
78 '
79
80 test_expect_success 'loose objects in alternate ODB are not repacked' '
81 mkdir alt_objects &&
82 echo $(pwd)/alt_objects >.git/objects/info/alternates &&
83 echo content3 >file3 &&
84 oid=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
85 git add file3 &&
86 test_tick &&
87 git commit -m commit_file3 &&
88 git repack -a -d -l &&
89 git prune-packed &&
90 test_has_duplicate_object false
91 '
92
93 test_expect_success SYMLINKS '--local keeps packs when alternate is objectdir ' '
94 test_when_finished "rm -rf repo" &&
95 git init repo &&
96 test_commit -C repo A &&
97 (
98 cd repo &&
99 git repack -a &&
100 ls .git/objects/pack/*.pack >../expect &&
101 ln -s objects .git/alt_objects &&
102 echo "$(pwd)/.git/alt_objects" >.git/objects/info/alternates &&
103 git repack -a -d -l &&
104 ls .git/objects/pack/*.pack >../actual
105 ) &&
106 test_cmp expect actual
107 '
108
109 test_expect_success '--local disables writing bitmaps when connected to alternate ODB' '
110 test_when_finished "rm -rf shared member" &&
111
112 git init shared &&
113 git clone --shared shared member &&
114 (
115 cd member &&
116 test_commit "object" &&
117 GIT_TEST_MULTI_PACK_INDEX=0 git repack -Adl --write-bitmap-index 2>err &&
118 cat >expect <<-EOF &&
119 warning: disabling bitmap writing, as some objects are not being packed
120 EOF
121 test_cmp expect err &&
122 test_path_is_missing .git/objects/pack-*.bitmap
123 )
124 '
125
126 test_expect_success 'packed obs in alt ODB are repacked even when local repo is packless' '
127 mkdir alt_objects/pack &&
128 mv .git/objects/pack/* alt_objects/pack &&
129 git repack -a &&
130 test_no_missing_in_packs
131 '
132
133 test_expect_success 'packed obs in alt ODB are repacked when local repo has packs' '
134 rm -f .git/objects/pack/* &&
135 echo new_content >>file1 &&
136 git add file1 &&
137 test_tick &&
138 git commit -m more_content &&
139 git repack &&
140 git repack -a -d &&
141 test_no_missing_in_packs
142 '
143
144 test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
145 # swap the .keep so the commit object is in the pack with .keep
146 for p in alt_objects/pack/*.pack
147 do
148 base_name=$(basename $p .pack) &&
149 if test_path_is_file alt_objects/pack/$base_name.keep
150 then
151 rm alt_objects/pack/$base_name.keep
152 else
153 touch alt_objects/pack/$base_name.keep
154 fi || return 1
155 done &&
156 git repack -a -d &&
157 test_no_missing_in_packs
158 '
159
160 test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
161 rm -f alt_objects/pack/*.keep &&
162 mv .git/objects/pack/* alt_objects/pack/ &&
163 coid=$(git rev-parse HEAD^{commit}) &&
164 git reset --hard HEAD^ &&
165 test_tick &&
166 git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
167 # The pack-objects call on the next line is equivalent to
168 # git repack -A -d without the call to prune-packed
169 git pack-objects --honor-pack-keep --non-empty --all --reflog \
170 --unpack-unreachable </dev/null pack &&
171 rm -f .git/objects/pack/* &&
172 mv pack-* .git/objects/pack/ &&
173 git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
174 ! grep "^$coid " packlist &&
175 echo >.git/objects/info/alternates &&
176 test_must_fail git show $coid
177 '
178
179 test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' '
180 echo $(pwd)/alt_objects >.git/objects/info/alternates &&
181 echo "$coid" | git pack-objects --non-empty --all --reflog pack &&
182 rm -f .git/objects/pack/* &&
183 mv pack-* .git/objects/pack/ &&
184 # The pack-objects call on the next line is equivalent to
185 # git repack -A -d without the call to prune-packed
186 git pack-objects --honor-pack-keep --non-empty --all --reflog \
187 --unpack-unreachable </dev/null pack &&
188 rm -f .git/objects/pack/* &&
189 mv pack-* .git/objects/pack/ &&
190 git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
191 ! grep "^$coid " &&
192 echo >.git/objects/info/alternates &&
193 test_must_fail git show $coid
194 '
195
196 test_expect_success 'objects made unreachable by grafts only are kept' '
197 test_tick &&
198 git commit --allow-empty -m "commit 4" &&
199 H0=$(git rev-parse HEAD) &&
200 H1=$(git rev-parse HEAD^) &&
201 H2=$(git rev-parse HEAD^^) &&
202 echo "$H0 $H2" >.git/info/grafts &&
203 git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
204 git repack -a -d &&
205 git cat-file -t $H1
206 '
207
208 test_expect_success 'repack --keep-pack' '
209 test_create_repo keep-pack &&
210 (
211 cd keep-pack &&
212 P1=$(commit_and_pack 1) &&
213 P2=$(commit_and_pack 2) &&
214 P3=$(commit_and_pack 3) &&
215 P4=$(commit_and_pack 4) &&
216 ls .git/objects/pack/*.pack >old-counts &&
217 test_line_count = 4 old-counts &&
218 git repack -a -d --keep-pack $P1 --keep-pack $P4 &&
219 ls .git/objects/pack/*.pack >new-counts &&
220 grep -q $P1 new-counts &&
221 grep -q $P4 new-counts &&
222 test_line_count = 3 new-counts &&
223 git fsck
224 )
225 '
226
227 test_expect_success 'bitmaps are created by default in bare repos' '
228 git clone --bare .git bare.git &&
229 rm -f bare.git/objects/pack/*.bitmap &&
230 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 \
231 git -C bare.git repack -ad &&
232 bitmap=$(ls bare.git/objects/pack/*.bitmap) &&
233 test_path_is_file "$bitmap"
234 '
235
236 test_expect_success 'incremental repack does not complain' '
237 git -C bare.git repack -q 2>repack.err &&
238 test_must_be_empty repack.err
239 '
240
241 test_expect_success 'bitmaps can be disabled on bare repos' '
242 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 \
243 git -c repack.writeBitmaps=false -C bare.git repack -ad &&
244 bitmap=$(ls bare.git/objects/pack/*.bitmap || :) &&
245 test -z "$bitmap"
246 '
247
248 test_expect_success 'no bitmaps created if .keep files present' '
249 pack=$(ls bare.git/objects/pack/*.pack) &&
250 test_path_is_file "$pack" &&
251 keep=${pack%.pack}.keep &&
252 test_when_finished "rm -f \"\$keep\"" &&
253 >"$keep" &&
254 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 \
255 git -C bare.git repack -ad 2>stderr &&
256 test_must_be_empty stderr &&
257 find bare.git/objects/pack/ -type f -name "*.bitmap" >actual &&
258 test_must_be_empty actual
259 '
260
261 test_expect_success 'auto-bitmaps do not complain if unavailable' '
262 test_config -C bare.git pack.packSizeLimit 1M &&
263 blob=$(test-tool genrandom big $((1024*1024)) |
264 git -C bare.git hash-object -w --stdin) &&
265 git -C bare.git update-ref refs/tags/big $blob &&
266 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 \
267 git -C bare.git repack -ad 2>stderr &&
268 test_must_be_empty stderr &&
269 find bare.git/objects/pack -type f -name "*.bitmap" >actual &&
270 test_must_be_empty actual
271 '
272
273 objdir=.git/objects
274 midx=$objdir/pack/multi-pack-index
275
276 test_expect_success 'setup for --write-midx tests' '
277 git init midx &&
278 (
279 cd midx &&
280 git config core.multiPackIndex true &&
281
282 test_commit base
283 )
284 '
285
286 test_expect_success '--write-midx unchanged' '
287 (
288 cd midx &&
289 GIT_TEST_MULTI_PACK_INDEX=0 git repack &&
290 test_path_is_missing $midx &&
291 test_path_is_missing $midx-*.bitmap &&
292
293 GIT_TEST_MULTI_PACK_INDEX=0 git repack --write-midx &&
294
295 test_path_is_file $midx &&
296 test_path_is_missing $midx-*.bitmap &&
297 test_midx_consistent $objdir
298 )
299 '
300
301 test_expect_success '--write-midx with a new pack' '
302 (
303 cd midx &&
304 test_commit loose &&
305
306 GIT_TEST_MULTI_PACK_INDEX=0 git repack --write-midx &&
307
308 test_path_is_file $midx &&
309 test_path_is_missing $midx-*.bitmap &&
310 test_midx_consistent $objdir
311 )
312 '
313
314 test_expect_success '--write-midx with -b' '
315 (
316 cd midx &&
317 GIT_TEST_MULTI_PACK_INDEX=0 git repack -mb &&
318
319 test_path_is_file $midx &&
320 test_path_is_file $midx-*.bitmap &&
321 test_midx_consistent $objdir
322 )
323 '
324
325 test_expect_success '--write-midx with -d' '
326 (
327 cd midx &&
328 test_commit repack &&
329
330 GIT_TEST_MULTI_PACK_INDEX=0 git repack -Ad --write-midx &&
331
332 test_path_is_file $midx &&
333 test_path_is_missing $midx-*.bitmap &&
334 test_midx_consistent $objdir
335 )
336 '
337
338 test_expect_success 'cleans up MIDX when appropriate' '
339 (
340 cd midx &&
341
342 test_commit repack-2 &&
343 GIT_TEST_MULTI_PACK_INDEX=0 git repack -Adb --write-midx &&
344
345 checksum=$(midx_checksum $objdir) &&
346 test_path_is_file $midx &&
347 test_path_is_file $midx-$checksum.bitmap &&
348
349 test_commit repack-3 &&
350 GIT_TEST_MULTI_PACK_INDEX=0 git repack -Adb --write-midx &&
351
352 test_path_is_file $midx &&
353 test_path_is_missing $midx-$checksum.bitmap &&
354 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
355
356 test_commit repack-4 &&
357 GIT_TEST_MULTI_PACK_INDEX=0 git repack -Adb &&
358
359 find $objdir/pack -type f -name "multi-pack-index*" >files &&
360 test_must_be_empty files
361 )
362 '
363
364 test_expect_success '--write-midx with preferred bitmap tips' '
365 git init midx-preferred-tips &&
366 test_when_finished "rm -fr midx-preferred-tips" &&
367 (
368 cd midx-preferred-tips &&
369
370 test_commit_bulk --message="%s" 103 &&
371
372 git log --format="%H" >commits.raw &&
373 sort <commits.raw >commits &&
374
375 git log --format="create refs/tags/%s/%s %H" HEAD >refs &&
376 git update-ref --stdin <refs &&
377
378 git repack --write-midx --write-bitmap-index &&
379 test_path_is_file $midx &&
380 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
381
382 test-tool bitmap list-commits | sort >bitmaps &&
383 comm -13 bitmaps commits >before &&
384 test_line_count = 1 before &&
385
386 rm -fr $midx-$(midx_checksum $objdir).bitmap &&
387 rm -fr $midx &&
388
389 # instead of constructing the snapshot ourselves (c.f., the test
390 # "write a bitmap with --refs-snapshot (preferred tips)" in
391 # t5326), mark the missing commit as preferred by adding it to
392 # the pack.preferBitmapTips configuration.
393 git for-each-ref --format="%(refname:rstrip=1)" \
394 --points-at="$(cat before)" >missing &&
395 git config pack.preferBitmapTips "$(cat missing)" &&
396 git repack --write-midx --write-bitmap-index &&
397
398 test-tool bitmap list-commits | sort >bitmaps &&
399 comm -13 bitmaps commits >after &&
400
401 ! test_cmp before after
402 )
403 '
404
405 # The first argument is expected to be a filename
406 # and that file should contain the name of a .idx
407 # file. Send the list of objects in that .idx file
408 # into stdout.
409 get_sorted_objects_from_pack () {
410 git show-index <$(cat "$1") >raw &&
411 cut -d" " -f2 raw
412 }
413
414 test_expect_success '--write-midx -b packs non-kept objects' '
415 git init repo &&
416 test_when_finished "rm -fr repo" &&
417 (
418 cd repo &&
419
420 # Create a kept pack-file
421 test_commit base &&
422 git repack -ad &&
423 find $objdir/pack -name "*.idx" >before &&
424 test_line_count = 1 before &&
425 before_name=$(cat before) &&
426 >${before_name%.idx}.keep &&
427
428 # Create a non-kept pack-file
429 test_commit other &&
430 git repack &&
431
432 # Create loose objects
433 test_commit loose &&
434
435 # Repack everything
436 git repack --write-midx -a -b -d &&
437
438 # There should be two pack-files now, the
439 # old, kept pack and the new, non-kept pack.
440 find $objdir/pack -name "*.idx" | sort >after &&
441 test_line_count = 2 after &&
442 find $objdir/pack -name "*.keep" >kept &&
443 kept_name=$(cat kept) &&
444 echo ${kept_name%.keep}.idx >kept-idx &&
445 test_cmp before kept-idx &&
446
447 # Get object list from the kept pack.
448 get_sorted_objects_from_pack before >old.objects &&
449
450 # Get object list from the one non-kept pack-file
451 comm -13 before after >new-pack &&
452 test_line_count = 1 new-pack &&
453 get_sorted_objects_from_pack new-pack >new.objects &&
454
455 # None of the objects in the new pack should
456 # exist within the kept pack.
457 comm -12 old.objects new.objects >shared.objects &&
458 test_must_be_empty shared.objects
459 )
460 '
461
462 test_expect_success '--write-midx removes stale pack-based bitmaps' '
463 rm -fr repo &&
464 git init repo &&
465 test_when_finished "rm -fr repo" &&
466 (
467 cd repo &&
468 test_commit base &&
469 GIT_TEST_MULTI_PACK_INDEX=0 git repack -Ab &&
470
471 pack_bitmap=$(ls $objdir/pack/pack-*.bitmap) &&
472 test_path_is_file "$pack_bitmap" &&
473
474 test_commit tip &&
475 GIT_TEST_MULTI_PACK_INDEX=0 git repack -bm &&
476
477 test_path_is_file $midx &&
478 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
479 test_path_is_missing $pack_bitmap
480 )
481 '
482
483 test_expect_success '--write-midx with --pack-kept-objects' '
484 git init repo &&
485 test_when_finished "rm -fr repo" &&
486 (
487 cd repo &&
488
489 test_commit one &&
490 test_commit two &&
491
492 one="$(echo "one" | git pack-objects --revs $objdir/pack/pack)" &&
493 two="$(echo "one..two" | git pack-objects --revs $objdir/pack/pack)" &&
494
495 keep="$objdir/pack/pack-$one.keep" &&
496 touch "$keep" &&
497
498 git repack --write-midx --write-bitmap-index --geometric=2 -d \
499 --pack-kept-objects &&
500
501 test_path_is_file $keep &&
502 test_path_is_file $midx &&
503 test_path_is_file $midx-$(midx_checksum $objdir).bitmap
504 )
505 '
506
507 test_expect_success TTY '--quiet disables progress' '
508 test_terminal env GIT_PROGRESS_DELAY=0 \
509 git -C midx repack -ad --quiet --write-midx 2>stderr &&
510 test_must_be_empty stderr
511 '
512
513 test_expect_success 'clean up .tmp-* packs on error' '
514 test_must_fail ok=sigpipe git \
515 -c repack.cruftwindow=bogus \
516 repack -ad --cruft &&
517 find $objdir/pack -name '.tmp-*' >tmpfiles &&
518 test_must_be_empty tmpfiles
519 '
520
521 test_expect_success 'repack -ad cleans up old .tmp-* packs' '
522 git rev-parse HEAD >input &&
523 git pack-objects $objdir/pack/.tmp-1234 <input &&
524 git repack -ad &&
525 find $objdir/pack -name '.tmp-*' >tmpfiles &&
526 test_must_be_empty tmpfiles
527 '
528
529 test_expect_success 'setup for update-server-info' '
530 git init update-server-info &&
531 test_commit -C update-server-info message
532 '
533
534 test_server_info_present () {
535 test_path_is_file update-server-info/.git/objects/info/packs &&
536 test_path_is_file update-server-info/.git/info/refs
537 }
538
539 test_server_info_missing () {
540 test_path_is_missing update-server-info/.git/objects/info/packs &&
541 test_path_is_missing update-server-info/.git/info/refs
542 }
543
544 test_server_info_cleanup () {
545 rm -f update-server-info/.git/objects/info/packs update-server-info/.git/info/refs &&
546 test_server_info_missing
547 }
548
549 test_expect_success 'updates server info by default' '
550 test_server_info_cleanup &&
551 git -C update-server-info repack &&
552 test_server_info_present
553 '
554
555 test_expect_success '-n skips updating server info' '
556 test_server_info_cleanup &&
557 git -C update-server-info repack -n &&
558 test_server_info_missing
559 '
560
561 test_expect_success 'repack.updateServerInfo=true updates server info' '
562 test_server_info_cleanup &&
563 git -C update-server-info -c repack.updateServerInfo=true repack &&
564 test_server_info_present
565 '
566
567 test_expect_success 'repack.updateServerInfo=false skips updating server info' '
568 test_server_info_cleanup &&
569 git -C update-server-info -c repack.updateServerInfo=false repack &&
570 test_server_info_missing
571 '
572
573 test_expect_success '-n overrides repack.updateServerInfo=true' '
574 test_server_info_cleanup &&
575 git -C update-server-info -c repack.updateServerInfo=true repack -n &&
576 test_server_info_missing
577 '
578
579 test_expect_success '--expire-to stores pruned objects (now)' '
580 git init expire-to-now &&
581 (
582 cd expire-to-now &&
583
584 git branch -M main &&
585
586 test_commit base &&
587
588 git checkout -b cruft &&
589 test_commit --no-tag cruft &&
590
591 git rev-list --objects --no-object-names main..cruft >moved.raw &&
592 sort moved.raw >moved.want &&
593
594 git rev-list --all --objects --no-object-names >expect.raw &&
595 sort expect.raw >expect &&
596
597 git checkout main &&
598 git branch -D cruft &&
599 git reflog expire --all --expire=all &&
600
601 git init --bare expired.git &&
602 git repack -d \
603 --cruft --cruft-expiration="now" \
604 --expire-to="expired.git/objects/pack/pack" &&
605
606 expired="$(ls expired.git/objects/pack/pack-*.idx)" &&
607 test_path_is_file "${expired%.idx}.mtimes" &&
608
609 # Since the `--cruft-expiration` is "now", the effective
610 # behavior is to move _all_ unreachable objects out to
611 # the location in `--expire-to`.
612 git show-index <$expired >expired.raw &&
613 cut -d" " -f2 expired.raw | sort >expired.objects &&
614 git rev-list --all --objects --no-object-names \
615 >remaining.objects &&
616
617 # ...in other words, the combined contents of this
618 # repository and expired.git should be the same as the
619 # set of objects we started with.
620 cat expired.objects remaining.objects | sort >actual &&
621 test_cmp expect actual &&
622
623 # The "moved" objects (i.e., those in expired.git)
624 # should be the same as the cruft objects which were
625 # expired in the previous step.
626 test_cmp moved.want expired.objects
627 )
628 '
629
630 test_expect_success '--expire-to stores pruned objects (5.minutes.ago)' '
631 git init expire-to-5.minutes.ago &&
632 (
633 cd expire-to-5.minutes.ago &&
634
635 git branch -M main &&
636
637 test_commit base &&
638
639 # Create two classes of unreachable objects, one which
640 # is older than 5 minutes (stale), and another which is
641 # newer (recent).
642 for kind in stale recent
643 do
644 git checkout -b $kind main &&
645 test_commit --no-tag $kind || return 1
646 done &&
647
648 git rev-list --objects --no-object-names main..stale >in &&
649 stale="$(git pack-objects $objdir/pack/pack <in)" &&
650 mtime="$(test-tool chmtime --get =-600 $objdir/pack/pack-$stale.pack)" &&
651
652 # expect holds the set of objects we expect to find in
653 # this repository after repacking
654 git rev-list --objects --no-object-names recent >expect.raw &&
655 sort expect.raw >expect &&
656
657 # moved.want holds the set of objects we expect to find
658 # in expired.git
659 git rev-list --objects --no-object-names main..stale >out &&
660 sort out >moved.want &&
661
662 git checkout main &&
663 git branch -D stale recent &&
664 git reflog expire --all --expire=all &&
665 git prune-packed &&
666
667 git init --bare expired.git &&
668 git repack -d \
669 --cruft --cruft-expiration=5.minutes.ago \
670 --expire-to="expired.git/objects/pack/pack" &&
671
672 # Some of the remaining objects in this repository are
673 # unreachable, so use `cat-file --batch-all-objects`
674 # instead of `rev-list` to get their names
675 git cat-file --batch-all-objects --batch-check="%(objectname)" \
676 >remaining.objects &&
677 sort remaining.objects >actual &&
678 test_cmp expect actual &&
679
680 (
681 cd expired.git &&
682
683 expired="$(ls objects/pack/pack-*.mtimes)" &&
684 test-tool pack-mtimes $(basename $expired) >out &&
685 cut -d" " -f1 out | sort >../moved.got &&
686
687 # Ensure that there are as many objects with the
688 # expected mtime as were moved to expired.git.
689 #
690 # In other words, ensure that the recorded
691 # mtimes of any moved objects was written
692 # correctly.
693 grep " $mtime$" out >matching &&
694 test_line_count = $(wc -l <../moved.want) matching
695 ) &&
696 test_cmp moved.want moved.got
697 )
698 '
699
700 test_done