Re: [PATCH v4 9/9] repack: exclude cruft pack(s) from the MIDX where possible
- From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
- Date
- Jun 19, 2025, 11:33 UTC
- Message-ID
- <lfrgmt2ukanevmcctzsnc422iv2l2nb3qmiddpsj6jnyvz4m4s@5eohhsm6knw3>
- In-Reply-To
- <52a069ef48f5a573c58a369b69827a40c7712247.1748473890.git.me@ttaylorr.com>
On Wed, May 28, 2025 at 07:20:35PM -0800, Taylor Blau wrote:
Show 80 quoted lines
> 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