]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-ort: unconditionally release attributes index
authorPatrick Steinhardt <ps@pks.im>
Wed, 14 Aug 2024 06:52:33 +0000 (08:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Aug 2024 17:08:00 +0000 (10:08 -0700)
We conditionally release the index used for reading gitattributes in
merge-ort based on whether or the index has been populated. This check
uses `cache_nr` as a condition. This isn't sufficient though, as the
variable may be zero even when some other parts of the index have been
populated. This leads to memory leaks when sparse checkouts are in use,
as we may not end up releasing the sparse checkout patterns.

Fix this issue by unconditionally releasing the index.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-ort.c
t/t3507-cherry-pick-conflict.sh
t/t6421-merge-partial-clone.sh
t/t6428-merge-conflicts-sparse.sh
t/t7817-grep-sparse-checkout.sh

index e9d01ac7f7ad344ee533e64ddf926ed2c06d1558..3752c7e595dc65a1b7550e0ac2b5015bb8301876 100644 (file)
@@ -689,8 +689,7 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
         */
        strmap_clear_func(&opti->conflicted, 0);
 
-       if (opti->attr_index.cache_nr) /* true iff opt->renormalize */
-               discard_index(&opti->attr_index);
+       discard_index(&opti->attr_index);
 
        /* Free memory used by various renames maps */
        for (i = MERGE_SIDE1; i <= MERGE_SIDE2; ++i) {
index f3947b400a3a89970e400d3c3f5dc5d690292d83..10e9c91dbbd0f0f2655a5f35c769ba2fa5a10444 100755 (executable)
@@ -13,6 +13,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
 TEST_CREATE_REPO_NO_TEMPLATE=1
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 pristine_detach () {
index 711b709e755268ab1d02986c8aaa8257c27b41ee..020375c80543f38cb2cba710e66d0cb52340d74a 100755 (executable)
@@ -26,6 +26,7 @@ test_description="limiting blob downloads when merging with partial clones"
 #                     underscore notation is to differentiate different
 #                     files that might be renamed into each other's paths.)
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-merge.sh
 
index 9919c3fa7cd4359ebe36e3b4b1cbbe99da227905..8a79bc2e921d433bb9db401c2f9c0f25a9908333 100755 (executable)
@@ -22,6 +22,7 @@ test_description="merge cases"
 #                     underscore notation is to differentiate different
 #                     files that might be renamed into each other's paths.)
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-merge.sh
 
index eb595645657fad7f1dce4cf5fca6ac57eeb6bfce..0ba7817fb76bc12abce00ddaaa2109a53a77ac84 100755 (executable)
@@ -33,6 +33,7 @@ should leave the following structure in the working tree:
 But note that sub2 should have the SKIP_WORKTREE bit set.
 '
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '