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

The "sparse_checkout_patterns" member was added to the "struct index_state" in 836e25c51b2 (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>

Ævar Arnfjörð Bjarmason committed Nov 8, 2022 at 19:17 UTC b5fcb1c006cd566b567a5249a53d3ee5a51f299a
4 files changed +8
read-cache.c
+5
@@ -2558,6 +2558,11 @@ int discard_index(struct index_state *istate)
2558 free_untracked_cache(istate->untracked);
2559 istate->untracked = NULL;
2560
2561 + if (istate->sparse_checkout_patterns) {
2562 + clear_pattern_list(istate->sparse_checkout_patterns);
2563 + FREE_AND_NULL(istate->sparse_checkout_patterns);
2564 + }
2565 +
2566 if (istate->ce_mem_pool) {
2567 mem_pool_discard(istate->ce_mem_pool, should_validate_cache_entries());
2568 FREE_AND_NULL(istate->ce_mem_pool);
t/t1011-read-tree-sparse-checkout.sh
+1
@@ -12,6 +12,7 @@ test_description='sparse checkout tests
12 '
13
14 TEST_CREATE_REPO_NO_TEMPLATE=1
15 +TEST_PASSES_SANITIZE_LEAK=true
16 . ./test-lib.sh
17 . "$TEST_DIRECTORY"/lib-read-tree.sh
18
t/t2018-checkout-branch.sh
+1
@@ -3,6 +3,7 @@
3 test_description='checkout'
4
5 TEST_CREATE_REPO_NO_TEMPLATE=1
6 +TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
8
9 # Arguments: [!] <branch> <oid> [<checkout options>]
t/t6435-merge-sparse.sh
+1
@@ -3,6 +3,7 @@
3 test_description='merge with sparse files'
4
5 TEST_CREATE_REPO_NO_TEMPLATE=1
6 +TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
8
9 # test_file $filename $content