Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> 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@xxxxxxxxx> > --- > 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.