Re: [PATCH 08/11] checkout: add a missing clear_unpack_trees_porcelain()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 30, 2022, 22:20 UTC
- Message-ID
- <xmqq35fldc9i.fsf@gitster.g>
- In-Reply-To
- <patch-08.11-94e28aa7ab3-20220630T175714Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 22 quoted lines
> 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 <avarab@gmail.com>
> ---
> 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.
Thanks.