summaryrefslogtreecommitdiffstats
path: root/t/t2072-restore-pathspec-file.sh
diff options
context:
space:
mode:
authorRubén Justo <rjusto@gmail.com>2024-03-14 19:08:58 +0100
committerJunio C Hamano <gitster@pobox.com>2024-03-14 19:58:04 +0100
commit2f64da0790900f9c83f697730047282b7d22f5b5 (patch)
tree114cebad0588be8f577eb1c9932ec1c7658f21a1 /t/t2072-restore-pathspec-file.sh
parentGit 2.44 (diff)
downloadgit-2f64da0790900f9c83f697730047282b7d22f5b5.tar.xz
git-2f64da0790900f9c83f697730047282b7d22f5b5.zip
checkout: plug some leaks in git-restore
In git-restore we need to free the pathspec and pathspec_from_file values from the struct checkout_opts. A simple fix could be to free them in cmd_restore, after the call to checkout_main returns, like we are doing [1][2] in the sibling function cmd_checkout. However, we can do even better. We have git-switch and git-restore, both of them spin-offs[3][4] of git-checkout. All three are implemented as thin wrappers around checkout_main. Considering this, it makes a lot of sense to do the cleanup closer to checkout_main. Move the cleanups, including the new_branch_info variable, to checkout_main. As a consequence, mark: t2070, t2071, t2072 and t6418 as leak-free. [1] 9081a421a6 (checkout: fix "branch info" memory leaks, 2021-11-16) [2] 7ce4088ab7 (parse-options: consistently allocate memory in fix_filename(), 2023-03-04) [3] d787d311db (checkout: split part of it to new command 'switch', 2019-03-29) [4] 46e91b663b (checkout: split part of it to new command 'restore', 2019-04-25) Signed-off-by: Rubén Justo <rjusto@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2072-restore-pathspec-file.sh')
-rwxr-xr-xt/t2072-restore-pathspec-file.sh1
1 files changed, 1 insertions, 0 deletions
diff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh
index 8198a1e578..86c9c88788 100755
--- a/t/t2072-restore-pathspec-file.sh
+++ b/t/t2072-restore-pathspec-file.sh
@@ -2,6 +2,7 @@
test_description='restore --pathspec-from-file'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_tick