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 Taylor Blau
parent 407b94280f
commit 0ae7f6b1da
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);
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) {
mem_pool_discard(istate->ce_mem_pool, should_validate_cache_entries());
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_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh

View file

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

View file

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