3 test_description
='git repack works correctly'
6 .
"${TEST_DIRECTORY}/lib-bitmap.sh"
7 .
"${TEST_DIRECTORY}/lib-midx.sh"
8 .
"${TEST_DIRECTORY}/lib-terminal.sh"
10 GIT_TEST_MULTI_PACK_INDEX
=0
11 GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL
=0
14 test_commit
"$@" 1>&2 &&
15 incrpackid
=$
(git pack-objects
--all --unpacked --incremental .git
/objects
/pack
/pack
</dev
/null
) &&
16 # Remove any loose object(s) created by test_commit, since they have
17 # already been packed. Leaving these around can create subtly different
18 # packs with `pack-objects`'s `--unpacked` option.
19 git prune-packed
1>&2 &&
20 echo pack-
${incrpackid}.pack
23 test_no_missing_in_packs
() {
24 myidx
=$
(ls -1 .git
/objects
/pack
/*.idx
) &&
25 test_path_is_file
"$myidx" &&
26 git verify-pack
-v alt_objects
/pack
/*.idx
>orig.raw
&&
27 sed -n -e "s/^\($OID_REGEX\).*/\1/p" orig.raw |
sort >orig
&&
28 git verify-pack
-v $myidx >dest.raw
&&
29 cut
-d" " -f1 dest.raw |
sort >dest
&&
30 comm -23 orig dest
>missing
&&
31 test_must_be_empty missing
34 # we expect $packid and $oid to be defined
35 test_has_duplicate_object
() {
36 want_duplicate_object
="$1"
37 found_duplicate_object
=false
38 for p
in .git
/objects
/pack
/*.idx
41 test "pack-$packid.idx" = "$idx" && continue
42 git verify-pack
-v $p >packlist ||
return $?
43 if grep "^$oid" packlist
45 found_duplicate_object
=true
46 echo "DUPLICATE OBJECT FOUND"
50 test "$want_duplicate_object" = "$found_duplicate_object"
53 test_expect_success
'objects in packs marked .keep are not repacked' '
54 echo content1 >file1 &&
55 echo content2 >file2 &&
58 git commit -m initial_commit &&
60 # The first pack will contain all of the objects except one
61 git rev-list --objects --all >objs &&
62 grep -v file2 objs | git pack-objects pack &&
63 # The second pack will contain the excluded object
64 packid=$(grep file2 objs | git pack-objects pack) &&
66 git verify-pack -v pack-$packid.idx >packlist &&
67 oid=$(head -n 1 packlist | sed -e "s/^\($OID_REGEX\).*/\1/") &&
68 mv pack-* .git/objects/pack/ &&
69 git repack -A -d -l &&
71 test_has_duplicate_object false
74 test_expect_success
'writing bitmaps via command-line can duplicate .keep objects' '
75 # build on $oid, $packid, and .keep state from previous
77 test_has_duplicate_object true
80 test_expect_success
'writing bitmaps via config can duplicate .keep objects' '
81 # build on $oid, $packid, and .keep state from previous
82 git -c repack.writebitmaps=true repack -Adl &&
83 test_has_duplicate_object true
86 test_expect_success
'loose objects in alternate ODB are not repacked' '
88 echo $(pwd)/alt_objects >.git/objects/info/alternates &&
89 echo content3 >file3 &&
90 oid=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
93 git commit -m commit_file3 &&
94 git repack -a -d -l &&
96 test_has_duplicate_object false
99 test_expect_success SYMLINKS
'--local keeps packs when alternate is objectdir ' '
100 test_when_finished "rm -rf repo" &&
102 test_commit -C repo A &&
106 ls .git/objects/pack/*.pack >../expect &&
107 ln -s objects .git/alt_objects &&
108 echo "$(pwd)/.git/alt_objects" >.git/objects/info/alternates &&
109 git repack -a -d -l &&
110 ls .git/objects/pack/*.pack >../actual
112 test_cmp expect actual
115 test_expect_success
'--local disables writing bitmaps when connected to alternate ODB' '
116 test_when_finished "rm -rf shared member" &&
119 git clone --shared shared member &&
122 test_commit "object" &&
123 git repack -Adl --write-bitmap-index 2>err &&
124 cat >expect <<-EOF &&
125 warning: disabling bitmap writing, as some objects are not being packed
127 test_cmp expect err &&
128 test_path_is_missing .git/objects/pack-*.bitmap
132 test_expect_success
'packed obs in alt ODB are repacked even when local repo is packless' '
133 mkdir alt_objects/pack &&
134 mv .git/objects/pack/* alt_objects/pack &&
136 test_no_missing_in_packs
139 test_expect_success
'packed obs in alt ODB are repacked when local repo has packs' '
140 rm -f .git/objects/pack/* &&
141 echo new_content >>file1 &&
144 git commit -m more_content &&
147 test_no_missing_in_packs
150 test_expect_success
'packed obs in alternate ODB kept pack are repacked' '
151 # swap the .keep so the commit object is in the pack with .keep
152 for p in alt_objects/pack/*.pack
154 base_name=$(basename $p .pack) &&
155 if test_path_is_file alt_objects/pack/$base_name.keep
157 rm alt_objects/pack/$base_name.keep
159 touch alt_objects/pack/$base_name.keep
163 test_no_missing_in_packs
166 test_expect_success
'packed unreachable obs in alternate ODB are not loosened' '
167 rm -f alt_objects/pack/*.keep &&
168 mv .git/objects/pack/* alt_objects/pack/ &&
169 coid=$(git rev-parse HEAD^{commit}) &&
170 git reset --hard HEAD^ &&
172 git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
173 # The pack-objects call on the next line is equivalent to
174 # git repack -A -d without the call to prune-packed
175 git pack-objects --honor-pack-keep --non-empty --all --reflog \
176 --unpack-unreachable </dev/null pack &&
177 rm -f .git/objects/pack/* &&
178 mv pack-* .git/objects/pack/ &&
179 git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
180 ! grep "^$coid " packlist &&
181 echo >.git/objects/info/alternates &&
182 test_must_fail git show $coid
185 test_expect_success
'local packed unreachable obs that exist in alternate ODB are not loosened' '
186 echo $(pwd)/alt_objects >.git/objects/info/alternates &&
187 echo "$coid" | git pack-objects --non-empty --all --reflog pack &&
188 rm -f .git/objects/pack/* &&
189 mv pack-* .git/objects/pack/ &&
190 # The pack-objects call on the next line is equivalent to
191 # git repack -A -d without the call to prune-packed
192 git pack-objects --honor-pack-keep --non-empty --all --reflog \
193 --unpack-unreachable </dev/null pack &&
194 rm -f .git/objects/pack/* &&
195 mv pack-* .git/objects/pack/ &&
196 git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
198 echo >.git/objects/info/alternates &&
199 test_must_fail git show $coid
202 test_expect_success
'objects made unreachable by grafts only are kept' '
204 git commit --allow-empty -m "commit 4" &&
205 H0=$(git rev-parse HEAD) &&
206 H1=$(git rev-parse HEAD^) &&
207 H2=$(git rev-parse HEAD^^) &&
208 echo "$H0 $H2" >.git/info/grafts &&
209 git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
214 test_expect_success
'repack --keep-pack' '
215 test_create_repo keep-pack &&
218 # avoid producing different packs due to delta/base choices
219 git config pack.window 0 &&
220 P1=$(commit_and_pack 1) &&
221 P2=$(commit_and_pack 2) &&
222 P3=$(commit_and_pack 3) &&
223 P4=$(commit_and_pack 4) &&
224 ls .git/objects/pack/*.pack >old-counts &&
225 test_line_count = 4 old-counts &&
226 git repack -a -d --keep-pack $P1 --keep-pack $P4 &&
227 ls .git/objects/pack/*.pack >new-counts &&
228 grep -q $P1 new-counts &&
229 grep -q $P4 new-counts &&
230 test_line_count = 3 new-counts &&
233 P5=$(commit_and_pack --no-tag 5) &&
234 git reset --hard HEAD^ &&
235 git reflog expire --all --expire=all &&
236 rm -f ".git/objects/pack/${P5%.pack}.idx" &&
237 rm -f ".git/objects/info/commit-graph" &&
238 for from in $(find .git/objects/pack -type f -name "${P5%.pack}.*")
240 to="$(dirname "$from")/.tmp-1234-$(basename "$from")" &&
241 mv "$from" "$to" || return 1
244 # A .idx file without a .pack should not stop us from
245 # repacking what we can.
246 touch .git/objects/pack/pack-does-not-exist.idx &&
248 git repack --cruft -d --keep-pack $P1 --keep-pack $P4 &&
250 ls .git/objects/pack/*.pack >newer-counts &&
251 test_cmp new-counts newer-counts &&
256 test_expect_success
'repacking fails when missing .pack actually means missing objects' '
257 test_create_repo idx-without-pack &&
259 cd idx-without-pack &&
261 # Avoid producing different packs due to delta/base choices
262 git config pack.window 0 &&
263 P1=$(commit_and_pack 1) &&
264 P2=$(commit_and_pack 2) &&
265 P3=$(commit_and_pack 3) &&
266 P4=$(commit_and_pack 4) &&
267 ls .git/objects/pack/*.pack >old-counts &&
268 test_line_count = 4 old-counts &&
270 # Remove one .pack file
271 rm .git/objects/pack/$P2 &&
273 ls .git/objects/pack/*.pack >before-pack-dir &&
275 test_must_fail git fsck &&
276 test_must_fail env GIT_COMMIT_GRAPH_PARANOIA=true git repack --cruft -d 2>err &&
277 grep "bad object" err &&
279 # Before failing, the repack did not modify the
281 ls .git/objects/pack/*.pack >after-pack-dir &&
282 test_cmp before-pack-dir after-pack-dir
286 test_expect_success
'bitmaps are created by default in bare repos' '
287 git clone --bare .git bare.git &&
288 rm -f bare.git/objects/pack/*.bitmap &&
289 git -C bare.git repack -ad &&
290 bitmap=$(ls bare.git/objects/pack/*.bitmap) &&
291 test_path_is_file "$bitmap"
294 test_expect_success
'incremental repack does not complain' '
295 git -C bare.git repack -q 2>repack.err &&
296 test_must_be_empty repack.err
299 test_expect_success
'bitmaps can be disabled on bare repos' '
300 git -c repack.writeBitmaps=false -C bare.git repack -ad &&
301 bitmap=$(ls bare.git/objects/pack/*.bitmap || :) &&
305 test_expect_success
'no bitmaps created if .keep files present' '
306 pack=$(ls bare.git/objects/pack/*.pack) &&
307 test_path_is_file "$pack" &&
308 keep=${pack%.pack}.keep &&
309 test_when_finished "rm -f \"\$keep\"" &&
311 git -C bare.git repack -ad 2>stderr &&
312 test_must_be_empty stderr &&
313 find bare.git/objects/pack/ -type f -name "*.bitmap" >actual &&
314 test_must_be_empty actual
317 test_expect_success
'auto-bitmaps do not complain if unavailable' '
318 test_config -C bare.git pack.packSizeLimit 1M &&
319 blob=$(test-tool genrandom big $((1024*1024)) |
320 git -C bare.git hash-object -w --stdin) &&
321 git -C bare.git update-ref refs/tags/big $blob &&
322 git -C bare.git repack -ad 2>stderr &&
323 test_must_be_empty stderr &&
324 find bare.git/objects/pack -type f -name "*.bitmap" >actual &&
325 test_must_be_empty actual
328 test_expect_success
'repacking with a filter works' '
329 git -C bare.git repack -a -d &&
330 test_stdout_line_count = 1 ls bare.git/objects/pack/*.pack &&
331 git -C bare.git -c repack.writebitmaps=false repack -a -d --filter=blob:none &&
332 test_stdout_line_count = 2 ls bare.git/objects/pack/*.pack &&
333 commit_pack=$(test-tool -C bare.git find-pack -c 1 HEAD) &&
334 blob_pack=$(test-tool -C bare.git find-pack -c 1 HEAD:file1) &&
335 test "$commit_pack" != "$blob_pack" &&
336 tree_pack=$(test-tool -C bare.git find-pack -c 1 HEAD^{tree}) &&
337 test "$tree_pack" = "$commit_pack" &&
338 blob_pack2=$(test-tool -C bare.git find-pack -c 1 HEAD:file2) &&
339 test "$blob_pack2" = "$blob_pack"
342 test_expect_success
'--filter fails with --write-bitmap-index' '
343 test_must_fail git -C bare.git repack -a -d --write-bitmap-index --filter=blob:none
346 test_expect_success
'repacking with two filters works' '
347 git init two-filters &&
352 test_commit subdir_bar subdir/bar &&
353 test_commit subdir_baz subdir/baz
355 git clone --no-local --bare two-filters two-filters.git &&
357 cd two-filters.git &&
358 test_stdout_line_count = 1 ls objects/pack/*.pack &&
359 git -c repack.writebitmaps=false repack -a -d \
360 --filter=blob:none --filter=tree:1 &&
361 test_stdout_line_count = 2 ls objects/pack/*.pack &&
362 commit_pack=$(test-tool find-pack -c 1 HEAD) &&
363 blob_pack=$(test-tool find-pack -c 1 HEAD:foo.t) &&
364 root_tree_pack=$(test-tool find-pack -c 1 HEAD^{tree}) &&
365 subdir_tree_hash=$(git ls-tree --object-only HEAD -- subdir) &&
366 subdir_tree_pack=$(test-tool find-pack -c 1 "$subdir_tree_hash") &&
368 # Root tree and subdir tree are not in the same packfiles
369 test "$commit_pack" != "$blob_pack" &&
370 test "$commit_pack" = "$root_tree_pack" &&
371 test "$blob_pack" = "$subdir_tree_pack"
375 prepare_for_keep_packs
() {
376 git init keep-packs
&&
382 git clone
--no-local --bare keep-packs keep-packs.git
&&
387 # The first pack will contain all of the objects except one blob
388 git rev-list
--objects --all >objs
&&
389 grep -v "bar.t" objs | git pack-objects pack
&&
390 # The second pack will contain the excluded object and be kept
391 packid
=$
(grep "bar.t" objs | git pack-objects pack
) &&
392 >pack-
$packid.keep
&&
394 # Replace the existing pack with the 2 new ones
395 rm -f objects
/pack
/pack
* &&
396 mv pack-
* objects
/pack
/
400 test_expect_success
'--filter works with .keep packs' '
401 prepare_for_keep_packs &&
405 foo_pack=$(test-tool find-pack -c 1 HEAD:foo.t) &&
406 bar_pack=$(test-tool find-pack -c 1 HEAD:bar.t) &&
407 head_pack=$(test-tool find-pack -c 1 HEAD) &&
409 test "$foo_pack" != "$bar_pack" &&
410 test "$foo_pack" = "$head_pack" &&
412 git -c repack.writebitmaps=false repack -a -d --filter=blob:none &&
414 foo_pack_1=$(test-tool find-pack -c 1 HEAD:foo.t) &&
415 bar_pack_1=$(test-tool find-pack -c 1 HEAD:bar.t) &&
416 head_pack_1=$(test-tool find-pack -c 1 HEAD) &&
418 # Object bar is still only in the old .keep pack
419 test "$foo_pack_1" != "$foo_pack" &&
420 test "$bar_pack_1" = "$bar_pack" &&
421 test "$head_pack_1" != "$head_pack" &&
423 test "$foo_pack_1" != "$bar_pack_1" &&
424 test "$foo_pack_1" != "$head_pack_1" &&
425 test "$bar_pack_1" != "$head_pack_1"
429 test_expect_success
'--filter works with --pack-kept-objects and .keep packs' '
430 rm -rf keep-packs keep-packs.git &&
431 prepare_for_keep_packs &&
435 foo_pack=$(test-tool find-pack -c 1 HEAD:foo.t) &&
436 bar_pack=$(test-tool find-pack -c 1 HEAD:bar.t) &&
437 head_pack=$(test-tool find-pack -c 1 HEAD) &&
439 test "$foo_pack" != "$bar_pack" &&
440 test "$foo_pack" = "$head_pack" &&
442 git -c repack.writebitmaps=false repack -a -d --filter=blob:none \
443 --pack-kept-objects &&
445 foo_pack_1=$(test-tool find-pack -c 1 HEAD:foo.t) &&
446 test-tool find-pack -c 2 HEAD:bar.t >bar_pack_1 &&
447 head_pack_1=$(test-tool find-pack -c 1 HEAD) &&
449 test "$foo_pack_1" != "$foo_pack" &&
450 test "$foo_pack_1" != "$bar_pack" &&
451 test "$head_pack_1" != "$head_pack" &&
453 # Object bar is in both the old .keep pack and the new
454 # pack that contained the filtered out objects
455 grep "$bar_pack" bar_pack_1 &&
456 grep "$foo_pack_1" bar_pack_1 &&
457 test "$foo_pack_1" != "$head_pack_1"
461 test_expect_success
'--filter-to stores filtered out objects' '
462 git -C bare.git repack -a -d &&
463 test_stdout_line_count = 1 ls bare.git/objects/pack/*.pack &&
465 git init --bare filtered.git &&
466 git -C bare.git -c repack.writebitmaps=false repack -a -d \
468 --filter-to=../filtered.git/objects/pack/pack &&
469 test_stdout_line_count = 1 ls bare.git/objects/pack/pack-*.pack &&
470 test_stdout_line_count = 1 ls filtered.git/objects/pack/pack-*.pack &&
472 commit_pack=$(test-tool -C bare.git find-pack -c 1 HEAD) &&
473 blob_pack=$(test-tool -C bare.git find-pack -c 0 HEAD:file1) &&
474 blob_hash=$(git -C bare.git rev-parse HEAD:file1) &&
475 test -n "$blob_hash" &&
476 blob_pack=$(test-tool -C filtered.git find-pack -c 1 $blob_hash) &&
478 echo $(pwd)/filtered.git/objects >bare.git/objects/info/alternates &&
479 blob_pack=$(test-tool -C bare.git find-pack -c 1 HEAD:file1) &&
480 blob_content=$(git -C bare.git show $blob_hash) &&
481 test "$blob_content" = "content1"
484 test_expect_success
'--filter works with --max-pack-size' '
485 rm -rf filtered.git &&
486 git init --bare filtered.git &&
487 git init max-pack-size &&
491 # two blobs which exceed the maximum pack size
492 test-tool genrandom foo 1048576 >foo &&
493 git hash-object -w foo &&
494 test-tool genrandom bar 1048576 >bar &&
495 git hash-object -w bar &&
497 git commit -m "adding foo and bar"
499 git clone --no-local --bare max-pack-size max-pack-size.git &&
501 cd max-pack-size.git &&
502 git -c repack.writebitmaps=false repack -a -d --filter=blob:none \
504 --filter-to=../filtered.git/objects/pack/pack &&
505 echo $(cd .. && pwd)/filtered.git/objects >objects/info/alternates &&
507 # Check that the 3 blobs are in different packfiles in filtered.git
508 test_stdout_line_count = 3 ls ../filtered.git/objects/pack/pack-*.pack &&
509 test_stdout_line_count = 1 ls objects/pack/pack-*.pack &&
510 foo_pack=$(test-tool find-pack -c 1 HEAD:foo) &&
511 bar_pack=$(test-tool find-pack -c 1 HEAD:bar) &&
512 base_pack=$(test-tool find-pack -c 1 HEAD:base.t) &&
513 test "$foo_pack" != "$bar_pack" &&
514 test "$foo_pack" != "$base_pack" &&
515 test "$bar_pack" != "$base_pack" &&
516 for pack in "$foo_pack" "$bar_pack" "$base_pack"
518 case "$foo_pack" in */filtered.git/objects/pack/*) true ;; *) return 1 ;; esac
524 midx
=$objdir/pack
/multi-pack-index
526 test_expect_success
'setup for --write-midx tests' '
530 git config core.multiPackIndex true &&
536 test_expect_success
'--write-midx unchanged' '
540 test_path_is_missing $midx &&
541 test_path_is_missing $midx-*.bitmap &&
543 git repack --write-midx &&
545 test_path_is_file $midx &&
546 test_path_is_missing $midx-*.bitmap &&
547 test_midx_consistent $objdir
551 test_expect_success
'--write-midx with a new pack' '
556 git repack --write-midx &&
558 test_path_is_file $midx &&
559 test_path_is_missing $midx-*.bitmap &&
560 test_midx_consistent $objdir
564 test_expect_success
'--write-midx with -b' '
569 test_path_is_file $midx &&
570 test_path_is_file $midx-*.bitmap &&
571 test_midx_consistent $objdir
575 test_expect_success
'--write-midx with -d' '
578 test_commit repack &&
580 git repack -Ad --write-midx &&
582 test_path_is_file $midx &&
583 test_path_is_missing $midx-*.bitmap &&
584 test_midx_consistent $objdir
588 test_expect_success
'cleans up MIDX when appropriate' '
592 test_commit repack-2 &&
593 git repack -Adb --write-midx &&
595 checksum=$(midx_checksum $objdir) &&
596 test_path_is_file $midx &&
597 test_path_is_file $midx-$checksum.bitmap &&
599 test_commit repack-3 &&
600 git repack -Adb --write-midx &&
602 test_path_is_file $midx &&
603 test_path_is_missing $midx-$checksum.bitmap &&
604 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
606 test_commit repack-4 &&
609 find $objdir/pack -type f -name "multi-pack-index*" >files &&
610 test_must_be_empty files
614 test_expect_success
'--write-midx with preferred bitmap tips' '
615 git init midx-preferred-tips &&
616 test_when_finished "rm -fr midx-preferred-tips" &&
618 cd midx-preferred-tips &&
620 test_commit_bulk --message="%s" 103 &&
622 git log --format="%H" >commits.raw &&
623 sort <commits.raw >commits &&
625 git log --format="create refs/tags/%s/%s %H" HEAD >refs &&
626 git update-ref --stdin <refs &&
628 git repack --write-midx --write-bitmap-index &&
629 test_path_is_file $midx &&
630 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
632 test-tool bitmap list-commits | sort >bitmaps &&
633 comm -13 bitmaps commits >before &&
634 test_line_count = 1 before &&
636 rm -fr $midx-$(midx_checksum $objdir).bitmap &&
639 # instead of constructing the snapshot ourselves (c.f., the test
640 # "write a bitmap with --refs-snapshot (preferred tips)" in
641 # t5326), mark the missing commit as preferred by adding it to
642 # the pack.preferBitmapTips configuration.
643 git for-each-ref --format="%(refname:rstrip=1)" \
644 --points-at="$(cat before)" >missing &&
645 git config pack.preferBitmapTips "$(cat missing)" &&
646 git repack --write-midx --write-bitmap-index &&
648 test-tool bitmap list-commits | sort >bitmaps &&
649 comm -13 bitmaps commits >after &&
651 ! test_cmp before after
655 # The first argument is expected to be a filename
656 # and that file should contain the name of a .idx
657 # file. Send the list of objects in that .idx file
659 get_sorted_objects_from_pack
() {
660 git show-index
<$
(cat "$1") >raw
&&
664 test_expect_success
'--write-midx -b packs non-kept objects' '
666 test_when_finished "rm -fr repo" &&
670 # Create a kept pack-file
673 find $objdir/pack -name "*.idx" >before &&
674 test_line_count = 1 before &&
675 before_name=$(cat before) &&
676 >${before_name%.idx}.keep &&
678 # Create a non-kept pack-file
682 # Create loose objects
686 git repack --write-midx -a -b -d &&
688 # There should be two pack-files now, the
689 # old, kept pack and the new, non-kept pack.
690 find $objdir/pack -name "*.idx" | sort >after &&
691 test_line_count = 2 after &&
692 find $objdir/pack -name "*.keep" >kept &&
693 kept_name=$(cat kept) &&
694 echo ${kept_name%.keep}.idx >kept-idx &&
695 test_cmp before kept-idx &&
697 # Get object list from the kept pack.
698 get_sorted_objects_from_pack before >old.objects &&
700 # Get object list from the one non-kept pack-file
701 comm -13 before after >new-pack &&
702 test_line_count = 1 new-pack &&
703 get_sorted_objects_from_pack new-pack >new.objects &&
705 # None of the objects in the new pack should
706 # exist within the kept pack.
707 comm -12 old.objects new.objects >shared.objects &&
708 test_must_be_empty shared.objects
712 test_expect_success
'--write-midx removes stale pack-based bitmaps' '
715 test_when_finished "rm -fr repo" &&
721 pack_bitmap=$(ls $objdir/pack/pack-*.bitmap) &&
722 test_path_is_file "$pack_bitmap" &&
727 test_path_is_file $midx &&
728 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
729 test_path_is_missing $pack_bitmap
733 test_expect_success
'--write-midx with --pack-kept-objects' '
735 test_when_finished "rm -fr repo" &&
742 one="$(echo "one" | git pack-objects --revs $objdir/pack/pack)" &&
743 two="$(echo "one..two" | git pack-objects --revs $objdir/pack/pack)" &&
745 keep="$objdir/pack/pack-$one.keep" &&
748 git repack --write-midx --write-bitmap-index --geometric=2 -d \
749 --pack-kept-objects &&
751 test_path_is_file $keep &&
752 test_path_is_file $midx &&
753 test_path_is_file $midx-$(midx_checksum $objdir).bitmap
757 test_expect_success TTY
'--quiet disables progress' '
758 test_terminal env GIT_PROGRESS_DELAY=0 \
759 git -C midx repack -ad --quiet --write-midx 2>stderr &&
760 test_must_be_empty stderr
763 test_expect_success
'clean up .tmp-* packs on error' '
764 test_must_fail ok=sigpipe git \
765 -c repack.cruftwindow=bogus \
766 repack -ad --cruft &&
767 find $objdir/pack -name '.tmp-
*' >tmpfiles &&
768 test_must_be_empty tmpfiles
771 test_expect_success
'repack -ad cleans up old .tmp-* packs' '
772 git rev-parse HEAD >input &&
773 git pack-objects $objdir/pack/.tmp-1234 <input &&
775 find $objdir/pack -name '.tmp-
*' >tmpfiles &&
776 test_must_be_empty tmpfiles
779 test_expect_success
'setup for update-server-info' '
780 git init update-server-info &&
781 test_commit -C update-server-info message
784 test_server_info_present
() {
785 test_path_is_file update-server-info
/.git
/objects
/info
/packs
&&
786 test_path_is_file update-server-info
/.git
/info
/refs
789 test_server_info_missing
() {
790 test_path_is_missing update-server-info
/.git
/objects
/info
/packs
&&
791 test_path_is_missing update-server-info
/.git
/info
/refs
794 test_server_info_cleanup
() {
795 rm -f update-server-info
/.git
/objects
/info
/packs update-server-info
/.git
/info
/refs
&&
796 test_server_info_missing
799 test_expect_success
'updates server info by default' '
800 test_server_info_cleanup &&
801 git -C update-server-info repack &&
802 test_server_info_present
805 test_expect_success
'-n skips updating server info' '
806 test_server_info_cleanup &&
807 git -C update-server-info repack -n &&
808 test_server_info_missing
811 test_expect_success
'repack.updateServerInfo=true updates server info' '
812 test_server_info_cleanup &&
813 git -C update-server-info -c repack.updateServerInfo=true repack &&
814 test_server_info_present
817 test_expect_success
'repack.updateServerInfo=false skips updating server info' '
818 test_server_info_cleanup &&
819 git -C update-server-info -c repack.updateServerInfo=false repack &&
820 test_server_info_missing
823 test_expect_success
'-n overrides repack.updateServerInfo=true' '
824 test_server_info_cleanup &&
825 git -C update-server-info -c repack.updateServerInfo=true repack -n &&
826 test_server_info_missing