read-cache.c: clear and free "sparse_checkout_patterns"

The "sparse_checkout_patterns" member was added to the "struct
index_state" in 836e25c51b (sparse-checkout: hold pattern list in
index, 2021-03-30), but wasn't added to discard_index(). Let's do
that.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-11-08 19:17:40 +01:00 committed by Junio C Hamano
parent 03267e8656
commit b5fcb1c006
4 changed files with 8 additions and 0 deletions

View File

@ -2558,6 +2558,11 @@ int discard_index(struct index_state *istate)
free_untracked_cache(istate->untracked); free_untracked_cache(istate->untracked);
istate->untracked = NULL; istate->untracked = NULL;
if (istate->sparse_checkout_patterns) {
clear_pattern_list(istate->sparse_checkout_patterns);
FREE_AND_NULL(istate->sparse_checkout_patterns);
}
if (istate->ce_mem_pool) { if (istate->ce_mem_pool) {
mem_pool_discard(istate->ce_mem_pool, should_validate_cache_entries()); mem_pool_discard(istate->ce_mem_pool, should_validate_cache_entries());
FREE_AND_NULL(istate->ce_mem_pool); FREE_AND_NULL(istate->ce_mem_pool);

View File

@ -12,6 +12,7 @@ test_description='sparse checkout tests
' '
TEST_CREATE_REPO_NO_TEMPLATE=1 TEST_CREATE_REPO_NO_TEMPLATE=1
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh . "$TEST_DIRECTORY"/lib-read-tree.sh

View File

@ -3,6 +3,7 @@
test_description='checkout' test_description='checkout'
TEST_CREATE_REPO_NO_TEMPLATE=1 TEST_CREATE_REPO_NO_TEMPLATE=1
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
# Arguments: [!] <branch> <oid> [<checkout options>] # Arguments: [!] <branch> <oid> [<checkout options>]

View File

@ -3,6 +3,7 @@
test_description='merge with sparse files' test_description='merge with sparse files'
TEST_CREATE_REPO_NO_TEMPLATE=1 TEST_CREATE_REPO_NO_TEMPLATE=1
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
# test_file $filename $content # test_file $filename $content