@@ -369,10 +369,61 @@ test_expect_success '--write-midx with preferred bitmap tips' '
369369 )
370370'
371371
372+ # The first argument is expected to be a filename
373+ # and that file should contain the name of a .idx
374+ # file. Send the list of objects in that .idx file
375+ # into stdout.
376+ get_sorted_objects_from_pack () {
377+ git show-index < $( cat " $1 " ) > raw &&
378+ cut -d" " -f2 raw
379+ }
380+
372381test_expect_success ' --write-midx -b packs non-kept objects' '
373- GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
374- git repack --write-midx -a -b &&
375- test_subcommand_inexact git pack-objects --honor-pack-keep <trace.txt
382+ git init repo &&
383+ test_when_finished "rm -fr repo" &&
384+ (
385+ cd repo &&
386+
387+ # Create a kept pack-file
388+ test_commit base &&
389+ git repack -ad &&
390+ find $objdir/pack -name "*.idx" >before &&
391+ test_line_count = 1 before &&
392+ before_name=$(cat before) &&
393+ >${before_name%.idx}.keep &&
394+
395+ # Create a non-kept pack-file
396+ test_commit other &&
397+ git repack &&
398+
399+ # Create loose objects
400+ test_commit loose &&
401+
402+ # Repack everything
403+ git repack --write-midx -a -b -d &&
404+
405+ # There should be two pack-files now, the
406+ # old, kept pack and the new, non-kept pack.
407+ find $objdir/pack -name "*.idx" | sort >after &&
408+ test_line_count = 2 after &&
409+ find $objdir/pack -name "*.keep" >kept &&
410+ kept_name=$(cat kept) &&
411+ echo ${kept_name%.keep}.idx >kept-idx &&
412+ test_cmp before kept-idx &&
413+
414+ # Get object list from the kept pack.
415+ get_sorted_objects_from_pack before >old.objects &&
416+
417+ # Get object list from the one non-kept pack-file
418+ comm -13 before after >new-pack &&
419+ test_line_count = 1 new-pack &&
420+ get_sorted_objects_from_pack new-pack >new.objects &&
421+
422+ # None of the objects in the new pack should
423+ # exist within the kept pack.
424+ comm -12 old.objects new.objects >shared.objects &&
425+ test_must_be_empty shared.objects
426+ )
376427'
377428
378429test_expect_success TTY ' --quiet disables progress' '
0 commit comments