Re: [PATCH 08/11] checkout: add a missing clear_unpack_trees_porcelain()
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2022-06-30 23:35:43
On Thu, Jun 30 2022, Junio C Hamano wrote:
Ævar Arnfjörð Bjarmason [off-list ref] writes:quoted
In 1c41d2805e4 (unpack_trees_options: free messages when done, 2018-05-21) we started calling clear_unpack_trees_porcelain() on this codepath, but missed this error path, let's also clear what we've allocated in that case. Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> --- builtin/checkout.c | 1 + 1 file changed, 1 insertion(+)diff --git a/builtin/checkout.c b/builtin/checkout.c index 2eefda81d8c..3d6762106e8 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c@@ -750,6 +750,7 @@ static int merge_working_tree(const struct checkout_opts *opts, refresh_cache(REFRESH_QUIET); if (unmerged_cache()) { + clear_unpack_trees_porcelain(&topts); error(_("you need to resolve your current index first")); return 1; }Does refresh_cache(REFRESH_QUIET) depend on the porcelain error messages already set? If not another way to fix it may be to delay the call to setup_unpack_trees_porcelain() until it becomes needed. But the patch as posted is certainly an improvement.
Yes, that would work too, I can do it that way if you'd like. I was trying to keep these fixes as narrow as possible, and resist any temptations to re-arrange code so as to avoid allocations, which we can often do, but then instead of a 1-line diff it's 10, 50, 100... :) In this case it'll be somewhere around 10, and just a code-move, so maybe that's fine...