Re: [PATCH] checkout: plug some leaks in git-restore
On Wed, Mar 13, 2024 at 9:33 PM Rubén Justo <rjusto@gmail.com> wrote:
Show 19 quoted lines
> 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 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.
>
> Factor out the call to checkout_main in a function that does both the
> work and the cleanup, and use it in the three wrappers.
>
> As a consequence, mark: t2070, t2071, t2072 and t6418 as leak-free.
> ---