git/t/t5334-incremental-multi-pack-index.sh
Patrick Steinhardt 9d4855eef3 midx-write: fix leaking buffer
The buffer used to compute the final MIDX name is never released. Plug
this memory leak.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-30 11:23:07 -07:00

49 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
test_description='incremental multi-pack-index'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-midx.sh
GIT_TEST_MULTI_PACK_INDEX=0
export GIT_TEST_MULTI_PACK_INDEX
objdir=.git/objects
packdir=$objdir/pack
midxdir=$packdir/multi-pack-index.d
midx_chain=$midxdir/multi-pack-index-chain
test_expect_success 'convert non-incremental MIDX to incremental' '
test_commit base &&
git repack -ad &&
git multi-pack-index write &&
test_path_is_file $packdir/multi-pack-index &&
old_hash="$(midx_checksum $objdir)" &&
test_commit other &&
git repack -d &&
git multi-pack-index write --incremental &&
test_path_is_missing $packdir/multi-pack-index &&
test_path_is_file $midx_chain &&
test_line_count = 2 $midx_chain &&
grep $old_hash $midx_chain
'
compare_results_with_midx 'incremental MIDX'
test_expect_success 'convert incremental to non-incremental' '
test_commit squash &&
git repack -d &&
git multi-pack-index write &&
test_path_is_file $packdir/multi-pack-index &&
test_dir_is_empty $midxdir
'
compare_results_with_midx 'non-incremental MIDX conversion'
test_done