From: Junio C Hamano <gitster@pobox.com>
To: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH 1/2] replay: fail gracefully when a merge input is unreadable
Date: Wed, 19 Aug 2026 11:09:51 -0700 [thread overview]
Message-ID: <xmqqfr0augls.fsf@gitster.g> (raw)
In-Reply-To: <321af575e0a9e0c22c70c1809f6fbf0265b05d4c.1787092446.git.gitgitgadget@gmail.com> (Elijah Newren via GitGitGadget's message of "Tue, 18 Aug 2026 22:34:05 +0000")
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Elijah Newren <newren@gmail.com>
>
> When objects involved in the merge cannot be read, the merge machinery
> will return early with result.clean = -1, and result.tree left as NULL.
> pick_regular_commit() tested only "if (!result->clean)", ignoring the
> case where "clean < 0". That causes the code to try to use
> result->tree, resulting in a SIGSEGV.
>
> Handle clean < 0 explicitly; the merge machinery will already have printed
> messages such as "Could not read <object>" and "collecting merge info
> failed for trees...", so we don't need to add much detail beyond the
> fact that the merge failed.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
> replay.c | 7 +++++++
> t/t3650-replay-basics.sh | 35 +++++++++++++++++++++++++++++++++++
> 2 files changed, 42 insertions(+)
>
> diff --git a/replay.c b/replay.c
> index 463c900d6c..33e21b2032 100644
> --- a/replay.c
> +++ b/replay.c
> @@ -327,6 +327,13 @@ static struct commit *pick_regular_commit(struct repository *repo,
> merge_opt->ancestor = NULL;
> merge_opt->branch2 = NULL;
>
> + if (result->clean < 0) {
> + error(_("merge of %s onto %s failed"),
> + oid_to_hex(&pickme->object.oid),
> + oid_to_hex(&replayed_base->object.oid));
> + return NULL;
> + }
> +
> if (!result->clean)
> return NULL;
Hmph, so anything but "0 < result->clean" is a failure, but we by
mistake took any non-zero value as OK? That is an obvious mistake.
Well spotted and fixed.
> + # Ensure replay gracefully handles the missing object
> + test_must_fail git replay --onto onto base..side 2>err &&
> + test_grep ! "[Ss]egmentation" err &&
> + test_grep "Could not read\|collecting merge info failed" err
"test_must_fail" means "the tested command must fail voluntarily and
in a controlled way", so a segfaulting git-replay invocation would
not pass test_must_fail. Hence, there is no need to separately
test "test_grep ! '[sS]egmentation'".
Besides, the spelling used by strsignal() is implementation-defined,
so you cannot reliably grep for it anyway.
> + )
> +'
> +
> test_done
Thanks.
next prev parent reply other threads:[~2026-08-19 18:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 22:34 [PATCH 0/2] Objects treated as missing despite being present, due to race with geometric repacking Elijah Newren via GitGitGadget
2026-08-18 22:34 ` [PATCH 1/2] replay: fail gracefully when a merge input is unreadable Elijah Newren via GitGitGadget
2026-08-19 18:09 ` Junio C Hamano [this message]
2026-08-18 22:34 ` [PATCH 2/2] packfile: recover when a multi-pack-index names a removed pack Elijah Newren via GitGitGadget
2026-08-19 18:21 ` Junio C Hamano
2026-08-20 7:54 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqfr0augls.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=newren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.