On Wed, May 28, 2025 at 07:20:35PM -0800, Taylor Blau wrote: > diff --git a/t/t7704-repack-cruft.sh b/t/t7704-repack-cruft.sh > index 8aebfb45f5..2b0a55f8fd 100755 > --- a/t/t7704-repack-cruft.sh > +++ b/t/t7704-repack-cruft.sh > @@ -724,4 +724,94 @@ test_expect_success 'cruft repack respects --quiet' ' > ) > ' > > +setup_cruft_exclude_tests() { > + git init "$1" && > + ( > + cd "$1" && > + > + git config repack.midxMustContainCruft false && > + > + test_commit one && > + > + test_commit --no-tag two && > + two="$(git rev-parse HEAD)" && > + test_commit --no-tag three && > + three="$(git rev-parse HEAD)" && > + git reset --hard one && > + git reflog expire --all --expire=all && > + > + GIT_TEST_MULTI_PACK_INDEX=0 git repack --cruft -d && > + > + git merge $two && > + test_commit four > + ) > +} > + > +test_expect_success 'repack --write-midx excludes cruft where possible' ' > + setup_cruft_exclude_tests exclude-cruft-when-possible && > + ( > + cd exclude-cruft-when-possible && > + > + GIT_TEST_MULTI_PACK_INDEX=0 \ > + git repack -d --geometric=2 --write-midx --write-bitmap-index && > + > + test-tool read-midx --show-objects $objdir >midx && > + cruft="$(ls $packdir/*.mtimes)" && > + test_grep ! "$(basename "$cruft" .mtimes).idx" midx && > + > + git rev-list --all --objects --no-object-names >reachable.raw && > + sort reachable.raw >reachable.objects && > + awk "/\.pack$/ { print \$1 }" <midx | sort >midx.objects && > + > + test_cmp reachable.objects midx.objects > + ) > +' > + > +test_expect_success 'repack --write-midx includes cruft when instructed' ' > + setup_cruft_exclude_tests exclude-cruft-when-instructed && > + ( > + cd exclude-cruft-when-instructed && > + > + GIT_TEST_MULTI_PACK_INDEX=0 \ > + git -c repack.midxMustContainCruft=true repack \ > + -d --geometric=2 --write-midx --write-bitmap-index && > + > + test-tool read-midx --show-objects $objdir >midx && > + cruft="$(ls $packdir/*.mtimes)" && > + test_grep "$(basename "$cruft" .mtimes).idx" midx && > + > + git cat-file --batch-check="%(objectname)" --batch-all-objects \ > + >all.objects && > + awk "/\.pack$/ { print \$1 }" <midx | sort >midx.objects && > + > + test_cmp all.objects midx.objects > + ) > +' > + > +test_expect_success 'repack --write-midx includes cruft when necessary' ' > + setup_cruft_exclude_tests exclude-cruft-when-necessary && > + ( > + cd exclude-cruft-when-necessary && > + > + test_path_is_file $(ls $packdir/pack-*.mtimes) && > + ls $packdir/pack-*.idx | sort >packs.all && > + grep -o "pack-.*\.idx$" packs.all >in && this is introducing `grep -o` to our codebase, which is not in POSIX and therefore will not be portable (ex: AIX) something like (untested) : sed -n '/\(pack-.*\.idx$\)/\1/p' packs.all >in will likely work the same and be more portable. Carlo