Re: [PATCH 08/11] checkout: add a missing clear_unpack_trees_porcelain()
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jun 30, 2022, 23:34 UTC
- Message-ID
- <220701.86wncxbu7q.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <xmqq35fldc9i.fsf@gitster.g>
On Thu, Jun 30 2022, Junio C Hamano wrote:
Show 30 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> 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.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...