summaryrefslogtreecommitdiff
path: root/commit.c
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 11:58:04 -0700
commit2f64da0790900f9c83f697730047282b7d22f5b5 (patch)
tree114cebad0588be8f577eb1c9932ec1c7658f21a1 /commit.c
parent3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0 (diff)
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 'commit.c')
0 files changed, 0 insertions, 0 deletions