From: Taylor Blau <me@ttaylorr•com>
To: Elijah Newren via GitGitGadget <gitgitgadget@gmail•com>
Cc: git@vger•kernel.org, Elijah Newren <newren@gmail•com>
Subject: Re: [PATCH 2/7] merge-ort: maintain expected invariant for priv member
Date: Thu, 13 Jun 2024 18:59:02 -0400 [thread overview]
Message-ID: <Zmt5tiuGIpTHLHRC@nand.local> (raw)
In-Reply-To: <17c97301baa829a993cf8838deb9271add5bd1cd.1718310307.git.gitgitgadget@gmail.com>
On Thu, Jun 13, 2024 at 08:25:02PM +0000, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail•com>
>
> The calling convention for the merge machinery is
> One call to init_merge_options()
> One or more calls to merge_incore_[non]recursive()
> One call to merge_finalize()
> (possibly indirectly via merge_switch_to_result())
> Both merge_switch_to_result() and merge_finalize() expect
> opt->priv == NULL && result->priv != NULL
> which is supposed to be set up by our move_opt_priv_to_result_priv()
> function. However, two codepath dealing with error cases did not
s/codepath/&s/ ?
> execute this necessary logic, which could result in assertion failures
> (or, if assertions were compiled out, could result in segfaults). Fix
> the oversight and add a test that would have caught one of these
> problems.
>
> While at it, also tighten an existing test for a non-recursive merge
> to verify that it fails correctly, i.e. with the expected exit code
> rather than with an assertion failure.
I suspect that this test was flaky, too, since if the assertion errors
were compiled out and it died via a segfault, the test would have failed
outright as test_must_fail does not allow for segfaults typically.
So I'm glad to see us tightening up that area of the test suite.
> Reported-by: Matt Cree <matt.cree@gearset•com>
> Signed-off-by: Elijah Newren <newren@gmail•com>
> ---
> merge-ort.c | 3 ++-
> t/t6406-merge-attr.sh | 42 +++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/merge-ort.c b/merge-ort.c
> index 10f5a655f29..6ca7b0f9be4 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> @@ -5015,7 +5015,7 @@ static void move_opt_priv_to_result_priv(struct merge_options *opt,
> * to move it.
> */
> assert(opt->priv && !result->priv);
> - if (!opt->priv->call_depth) {
> + if (!opt->priv->call_depth || result->clean < 0) {
> result->priv = opt->priv;
> result->_properly_initialized = RESULT_INITIALIZED;
> opt->priv = NULL;
> @@ -5052,6 +5052,7 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,
> oid_to_hex(&side1->object.oid),
> oid_to_hex(&side2->object.oid));
> result->clean = -1;
> + move_opt_priv_to_result_priv(opt, result);
> return;
> }
> trace2_region_leave("merge", "collect_merge_info", opt->repo);
> diff --git a/t/t6406-merge-attr.sh b/t/t6406-merge-attr.sh
> index 156a1efacfe..b6db5c2cc36 100755
> --- a/t/t6406-merge-attr.sh
> +++ b/t/t6406-merge-attr.sh
> @@ -185,7 +185,7 @@ test_expect_success !WINDOWS 'custom merge driver that is killed with a signal'
>
> >./please-abort &&
> echo "* merge=custom" >.gitattributes &&
> - test_must_fail git merge main 2>err &&
> + test_expect_code 2 git merge main 2>err &&
> grep "^error: failed to execute internal merge" err &&
> git ls-files -u >output &&
> git diff --name-only HEAD >>output &&
> @@ -261,4 +261,44 @@ test_expect_success 'binary files with union attribute' '
> grep -i "warning.*cannot merge.*HEAD vs. bin-main" output
> '
>
> +test_expect_success !WINDOWS 'custom merge driver that is killed with a signal on recursive merge' '
> + test_when_finished "rm -f output please-abort" &&
> + test_when_finished "git checkout side" &&
> +
> + git reset --hard anchor &&
> +
> + git checkout -b base-a main^ &&
> + echo base-a >text &&
> + git commit -m base-a text &&
> +
> + git checkout -b base-b main^ &&
> + echo base-b >text &&
> + git commit -m base-b text &&
> +
> + git checkout -b recursive-a base-a &&
> + test_must_fail git merge base-b &&
Here and below, do you care about the particular exit code of merging as
above? IOW, should these be `test_expect_code`'s as well?
Thanks,
Taylor
next prev parent reply other threads:[~2024-06-13 22:59 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 20:25 [PATCH 0/7] Fix and improve some error codepaths in merge-ort Elijah Newren via GitGitGadget
2024-06-13 20:25 ` [PATCH 1/7] merge-ort: extract handling of priv member into reusable function Elijah Newren via GitGitGadget
2024-06-13 21:00 ` Junio C Hamano
2024-06-13 22:52 ` Taylor Blau
2024-06-13 20:25 ` [PATCH 2/7] merge-ort: maintain expected invariant for priv member Elijah Newren via GitGitGadget
2024-06-13 22:59 ` Taylor Blau [this message]
2024-06-19 2:58 ` Elijah Newren
2024-06-13 20:25 ` [PATCH 3/7] merge-ort: fix type of local 'clean' var in handle_content_merge() Elijah Newren via GitGitGadget
2024-06-13 20:25 ` [PATCH 4/7] merge-ort: clearer propagation of failure-to-function from merge_submodule Elijah Newren via GitGitGadget
2024-06-13 20:25 ` [PATCH 5/7] merge-ort: loosen commented requirements Elijah Newren via GitGitGadget
2024-06-13 20:25 ` [PATCH 6/7] merge-ort: upon merge abort, only show messages causing the abort Elijah Newren via GitGitGadget
2024-06-14 4:19 ` Eric Sunshine
2024-06-19 2:58 ` Elijah Newren
2024-06-13 20:25 ` [PATCH 7/7] merge-ort: convert more error() cases to path_msg() Elijah Newren via GitGitGadget
2024-06-13 23:04 ` [PATCH 0/7] Fix and improve some error codepaths in merge-ort Taylor Blau
2024-06-19 3:00 ` [PATCH v2 " Elijah Newren via GitGitGadget
2024-06-19 3:00 ` [PATCH v2 1/7] merge-ort: extract handling of priv member into reusable function Elijah Newren via GitGitGadget
2024-06-19 3:00 ` [PATCH v2 2/7] merge-ort: maintain expected invariant for priv member Elijah Newren via GitGitGadget
2024-06-28 2:09 ` Derrick Stolee
2024-06-19 3:00 ` [PATCH v2 3/7] merge-ort: fix type of local 'clean' var in handle_content_merge() Elijah Newren via GitGitGadget
2024-06-28 2:44 ` Derrick Stolee
2024-06-19 3:00 ` [PATCH v2 4/7] merge-ort: clearer propagation of failure-to-function from merge_submodule Elijah Newren via GitGitGadget
2024-06-28 2:12 ` Derrick Stolee
2024-06-28 2:38 ` Elijah Newren
2024-06-28 2:47 ` Derrick Stolee
2024-06-19 3:00 ` [PATCH v2 5/7] merge-ort: loosen commented requirements Elijah Newren via GitGitGadget
2024-06-19 3:00 ` [PATCH v2 6/7] merge-ort: upon merge abort, only show messages causing the abort Elijah Newren via GitGitGadget
2024-06-19 3:00 ` [PATCH v2 7/7] merge-ort: convert more error() cases to path_msg() Elijah Newren via GitGitGadget
2024-07-02 21:33 ` Jeff King
2024-07-03 15:48 ` Elijah Newren
2024-07-03 18:35 ` Junio C Hamano
2024-07-06 6:11 ` Jeff King
2024-06-28 2:45 ` [PATCH v2 0/7] Fix and improve some error codepaths in merge-ort Derrick Stolee
2024-06-28 17:11 ` Junio C Hamano
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=Zmt5tiuGIpTHLHRC@nand.local \
--to=me@ttaylorr$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitgitgadget@gmail$(echo .)com \
--cc=newren@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox